Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

LocalFilePlugin.h

00001 /*
00002    Copyright (C) 2002 the Strongroom project
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    @author Ewald Snel
00010 */
00011 
00012 #ifndef __LOCALFILEPLUGIN_H
00013 #define __LOCALFILEPLUGIN_H
00014 
00015 #include <pthread.h>
00016 
00017 #include <FilePlugin.h>
00018 #include <HashUtils.h>
00019 
00020 
00028 class LocalFilePlugin : public FilePlugin
00029 {
00030 public:
00031     LocalFilePlugin( const Config &cfg );
00032     ~LocalFilePlugin();
00033 
00034     bool init();
00035     
00036     CoreError create( NumID &fileid );
00037     CoreError open( NumID fileid, NumID &of );
00038     CoreError remove( NumID fileid );
00039 
00040     int64_t getLength( NumID fileid );
00041     CoreError write( NumID fileid, char *data, int length );
00042     CoreError read( NumID fileid, char *data, int length, int &bRead );
00043     CoreError close( NumID fileid );
00044 
00045 private:
00050     bool exists( NumID fileid );
00051 
00056     string localFileName( NumID fileid );
00057 
00058     string root;
00059     NumID openFileID;
00060     NumID currentFileID;
00061     pthread_mutex_t mutex;
00062     hash_map<NumID,pair<int,NumID>,_hash_NumID> openFiles;
00063     hash_map<NumID,int,_hash_NumID> fileLocks;
00064 };
00065 
00066 #endif

Generated on Wed Feb 18 13:45:55 2004 for strongroom by doxygen1.2.18