StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
sfsTest.C
1 #include <stdio.h>
2 #include <unistd.h>
3 #include "sfs_index.h"
4 #include <stdlib.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <string.h>
9 
10 
11 int buffer[1000];
12 
13 int main(int argc, char *argv[])
14 {
15  char name[20];
16  strcpy(name, "123456");
17 
18  if(argc > 1) {
19  strcpy(name,argv[1]);
20  }
21 
22  sfs_index idx;
23 
24 
25  memset((char *)buffer, 0xffffffff, sizeof(buffer));
26 
27  printf("Before: \n");
28  for(int i=0;i<20;i++) {
29  printf("%d -- 0x%08x\n",i,buffer[i]);
30  }
31 
32 
33  idx.putfileheader((char *)buffer, name, 0,0);
34 
35  printf("sizeof(SFS_File)=%ld\n",sizeof(SFS_File));
36 
37  printf("After: \n");
38  for(int i=0;i<20;i++) {
39  printf("%d -- 0x%08x\n",i,buffer[i]);
40  }
41 
42 }
43 
44 
45 // char filebuff[100000];
46 
47 
48 // char *b1 = "This is file 1\n\ntoasty in here.";
49 // char *b2 = "File 2 is shorter xx";
50 
51 // char *n1 = "dumbodropblahblahblah";
52 // char *n2 = "jeffdrop";
53 // char *b3 = "hello";
54 // char *b4 = "hello there dumbo";
55 
56 // int main(int argc, char *argv[])
57 // {
58 // int ret;
59 // sfs_index idx;
60 
61 // printf("sizeof(SFS_File) = %d\n",sizeof(SFS_File) );
62 
63 // ret = idx.mount("write2.sfs", O_WRONLY | O_CREAT | O_TRUNC);
64 
65 // //ret = idx.mountmem(filebuff, 100000, O_WRONLY | O_CREAT);
66 
67 // if(ret < 0) {
68 // printf("error mounting write.sfs\n");
69 // return 0;
70 // }
71 
72 // printf("mounted\n");
73 
74 // idx.write("/this/long/filename/a",b1,strlen(b1));
75 
76 // printf("write1\n");
77 
78 // idx.cd("/jeff");
79 
80 // printf("cd\n");
81 
82 // idx.write("bbbbb",b2,strlen(b2));
83 
84 // idx.write("injeff",b2,strlen(b2));
85 
86 // printf("write2\n");
87 
88 // idx.write("/500/a",b2,strlen(b2));
89 // idx.write("/50/a",b2,strlen(b2));
90 // idx.write("/5/a",b2,strlen(b2));
91 // idx.write("/100000/a",b2,strlen(b2));
92 // idx.write("/1/a",b2,strlen(b2));
93 // idx.write("/2/a",b2,strlen(b2));
94 // idx.write("/3/a",b2,strlen(b2));
95 // idx.write("/4/a",b2,strlen(b2));
96 
97 
98 
99 
100 // fs_iovec myfiles[2] = { { n1, b3, strlen(b3) },
101 // { n2, b4, strlen(b4) } };
102 
103 // printf("blah\n");
104 // int n = idx.getwritevsz(myfiles, 2);
105 // printf("n=%d\n",n);
106 // ret = idx.writev(myfiles, 2);
107 // printf("writevsize = %d (%d)\n",n,ret);
108 
109 
110 // int sz = idx.mountsz();
111 
112 // if(sz == -1) exit(0);
113 
114 // idx.umount();
115 
116 // idx.mount("write2.sfs", O_RDONLY);
117 // // ret = idx.mountmem(filebuff, sz, O_RDONLY);
118 // // printf("mount rdonly = %d\n",ret);
119 
120 // char buff[1000];
121 // memset(buff, 0, sizeof(buff));
122 // ret = idx.fileSize("/this/long/filename/a");
123 // printf("file a size = %d\n",ret);
124 
125 // ret = idx.read("/this/long/filename/a",buff, 1000);
126 // printf("file a: (%d):\n%s\n\n",ret,buff);
127 
128 // memset(buff, 0, sizeof(buff));
129 // ret = idx.read("/jeff/b",buff, 1000);
130 // printf("file b: (%d):\n%s\n\n",ret,buff);
131 
132 // memset(buff, 0, sizeof(buff));
133 // buff[0] = '\0';
134 // ret = idx.read("/jeff/dumbodrop",buff, 1000);
135 // printf("file invalid: (%d):\n%s\n\n",ret,buff);
136 
137 // idx.umount();
138 
139 // //int fd = open("xxx.sfs", O_WRONLY | O_CREAT,0666);
140 // // write(fd, filebuff, sz);
141 // //close(fd);
142 // }