[go: up one dir, main page]

Menu

[r73]: / client / testfs.cpp  Maximize  Restore  History

Download this file

57 lines (39 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <fsclient.h>
#include <iostream>
using namespace std;
using namespace cb;
int main(int argc, char** argv)
{
Sector::init(argv[1], atoi(argv[2]));
File* f1 = Sector::createFileHandle();
if (NULL == f1)
return -1;
if (f1->open("test.txt", 1) < 0)
{
cout << "error to open file." << endl;
return -1;
}
char buf[1024];
f1->read(buf, 0, 10);
string test = "**********Hello World!";
f1->write(test.c_str(), 20, test.length());
f1->close();
f1->open("test.txt");
int res = f1->read(buf, 0, 10);
buf[10] = '\0';
cout << "res = " << res << " " << buf << endl;
f1->write(test.c_str(), 20, test.length());
f1->close();
f1->open("test.txt");
f1->read(buf, 0, 10);
f1->write(test.c_str(), 20, test.length());
f1->close();
Sector::releaseFileHandle(f1);
CFileAttr attr;
Sector::stat("test.txt", attr);
cout << attr.m_pcName << " " << attr.m_llSize << endl;
Sector::stat("rate.txt", attr);
cout << attr.m_pcName << " " << attr.m_llSize << endl;
Sector::close();
return 1;
}