Changeset 25
- Timestamp:
- 11/04/07 00:19:11 (1 year ago)
- Files:
-
- tarfs/tarfs.c (modified) (5 diffs)
- vowfs/common.hxx (deleted)
- vowfs/db.cxx (added)
- vowfs/db.hxx (modified) (4 diffs)
- vowfs/dir.hxx (modified) (4 diffs)
- vowfs/file.cxx (added)
- vowfs/file.hxx (modified) (4 diffs)
- vowfs/vowfs.hxx (added)
- vowfs/xdelta.hxx (added)
- vowfs/xdelta3.c (added)
- vowfs/xdelta3.h (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tarfs/tarfs.c
r20 r25 10 10 11 11 #include <fuse.h> 12 13 #include "zlib.h"14 #include "bzlib.h"15 12 16 13 #include "tar.h" … … 196 193 197 194 /* Create a root directory of the tree */ 198 new=file_tree=create_dir(NULL);195 file_tree=create_dir(NULL); 199 196 200 197 while(true){ … … 238 235 else 239 236 return NULL; 240 241 /* Add inode attributes */ 242 int name_size=strlen(result); 243 memmove(new->file_name, result, name_size); 244 new->file_name[name_size]='\0'; 237 /* Add inode attributes */ int name_size=strlen(result); memmove(new->file_name, result, name_size); new->file_name[name_size]='\0'; 245 238 246 239 switch(header.typeflag){ … … 264 257 /* Jump to the next header */ 265 258 fseek(file, new->block_length, SEEK_CUR); 259 266 260 } 267 261 fflush(file); … … 313 307 int main(int argc, char **argv){ 314 308 /* Parse filepath and initialize the file tree */ 315 /* 316 int c; 317 while( (c=getopt(argc, argv, "f:")) != -1 ){ 318 switch(c){ 319 case 'f': 320 { 321 tar_file = fopen(optarg, "r"); 322 if( !tar_file ){ 323 eprintf("Invalid filename: %s\n", optarg); 324 return 1; 325 } 326 file_tree=tarfs_init(tar_file); 327 if( !file_tree ){ 328 eprintf("Invalid file: %s\n", optarg); 329 return 1; 330 } 331 break; 332 } 333 case '?': 334 default: 335 break; 336 } 337 } 338 309 if( argc != 3 ){ 310 eprintf("Use: %s directory filepath\n", argv[0]); 311 return 1; 312 } 313 314 tar_file = fopen(argv[2], "r"); 315 if( !tar_file ){ 316 eprintf("Invalid filename: %s\n", argv[2]); 317 return 1; 318 } 319 320 file_tree=tarfs_init(tar_file); 339 321 if( !file_tree ){ 340 eprintf(" Use: %s -f filepath\n", argv[0]);322 eprintf("Invalid filetype: %s\n", argv[2]); 341 323 return 1; 342 }*/ 343 tar_file = fopen("./contrib.tar", "r"); 344 345 file_tree=tarfs_init(tar_file); 346 347 if( !file_tree ){ 348 eprintf("A fatal error occoured...\n"); 349 return 1; 350 } 351 else{ 352 return fuse_main(argc, argv, &tarfs_oper); 353 } 354 } 324 } 325 326 return fuse_main(argc-1, argv, &tarfs_oper); 327 } vowfs/db.hxx
r24 r25 1 #include "common.hxx" 1 #ifndef _VoWFS_Database_Header 2 #define _VoWFS_Database_Header 3 4 #include <postgresql/postgres.hxx> 5 #include "vowfs.hxx" 6 7 /* TODO: Implement all get-er functions 8 * It isn't too difficult, but we 9 * need all of the SQL queries for 10 * them. 11 */ 2 12 3 13 namespace VoWFS{ 4 14 class Database{ 5 15 private: 16 PQconn *connection; 6 17 7 18 public: 8 Database();9 10 19 Database(string host, int port, string db_name, string user, string password); 20 ~Database(); 11 21 12 22 // File Handling Functions … … 17 27 File getFile(int file_id, int revision); 18 28 29 19 30 // Directory Handling Functions 20 31 int getDirId(string dir_path); … … 24 35 Dir getDir(int dir_id, int revision); 25 36 37 26 38 // Modular Command for SQL Queries 27 39 list<File> getFiles(string sql_command); … … 29 41 list<Dir> getDirs(string sql_command); 30 42 31 32 43 }; 33 44 }; 45 46 #endif 47 vowfs/dir.hxx
r23 r25 1 #include "common.hxx" 1 #ifndef _VoWFS_Directory_Header_ 2 #define _VoWFS_Directory_Header_ 3 4 #include "vowfs.hxx" 2 5 3 6 namespace VoWFS{ … … 7 10 8 11 private: 9 // The connection to the databse10 12 static int Database db; 11 13 … … 28 30 29 31 public: 32 Dir(); 33 Dir(Databse db); 34 35 // TODO: Fill dir 36 Dir(PQresult *pqdata, int row); 37 30 38 int revisionId(){ 31 39 return revision_id; … … 56 64 } 57 65 58 // TODO Query the databse, get the data, and return it 59 list<File> listFileContents(); 66 list<File> listFileContents(){ 67 // TODO: What is the Query for Files 68 return file_list=db.getFiles(""); 69 } 70 60 71 61 // TODO Query the databse, get the data, and return it 62 list<File> listDirContents(); 72 list<File> listDirContents(){ 73 // TODO: What is the Query for Directories 74 return dir_list=db.getDirs(""); 75 } 63 76 }; 64 77 }; 78 79 #endif 80 vowfs/file.hxx
r22 r25 1 #include "common.hxx" 1 #ifndef _VoWFS_File_Header_ 2 #define _VoWFS_File_Header_ 3 4 #include "vowfs.hxx" 2 5 3 6 namespace VoWFS{ 4 7 class File{ 5 6 friend class Database;7 8 8 private: 9 // The connection to the databse10 9 static int Database db; 10 11 static int XDelta diff; 11 12 12 13 int revision_id; … … 15 16 int parent_dir_id; 16 17 17 /* file_size should also be stored in the databse so that 18 * the data does not need to be requested for a file that we 19 * only need the size of (i.e. for a directory listing). It 20 * also provides a mechanism for error checking 18 /* file_size should also be stored in the databse because the 19 * size of the diff is different than the size of the expanded 20 * file. 21 21 */ 22 22 int file_size; … … 38 38 39 39 public: 40 File(); 41 42 File(Databse db, XDelta diff); 43 44 // TODO: Fill file 45 File(PQresult *pqdata, int row); 46 40 47 int revisionId(){ 41 48 return revision_id; … … 78 85 } 79 86 80 // TODO Query the databse, get the data, and return it 81 char *fileData(); 87 char *readData(); 82 88 }; 83 89 }; 90 91 #endif 92
