[sword-cvs] sword/include filemgr.h,1.16,1.17

sword@www.crosswire.org sword@www.crosswire.org
Mon, 3 Mar 2003 10:02:49 -0700


Update of /usr/local/cvsroot/sword/include
In directory www:/tmp/cvs-serv29441/include

Modified Files:
	filemgr.h 
Log Message:
Martin: Made the destructor and constructor of FileDesc
private, so they can only be called by FileMgr, which they should be.


Index: filemgr.h
===================================================================
RCS file: /usr/local/cvsroot/sword/include/filemgr.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** filemgr.h	25 Feb 2003 04:12:47 -0000	1.16
--- filemgr.h	3 Mar 2003 17:02:46 -0000	1.17
***************
*** 32,35 ****
--- 32,38 ----
  class SWDLLEXPORT FileMgr;
  
+ /**
+ * This class represents one file. It works with the FileMgr object.
+ */
  class SWDLLEXPORT FileDesc
  {
***************
*** 42,56 ****
    FileDesc *next;
  
- public:
     FileDesc (FileMgr * parent, const char *path, int mode, int perms, bool tryDowngrade);
     virtual ~FileDesc ();
    int getFd ();
    char *path;
    int mode;
    int perms;
    bool tryDowngrade;
  };
  
! 
  class FileMgr
  {
--- 45,74 ----
    FileDesc *next;
  
     FileDesc (FileMgr * parent, const char *path, int mode, int perms, bool tryDowngrade);
     virtual ~FileDesc ();
+ 
+ public:
+ 	/** @return File handle.
+ 	*/
    int getFd ();
+ 	/** Path to file.
+ 	*/
    char *path;
+ 	/** File access mode.
+ 	*/
    int mode;
+ 	/** File permissions.
+ 	*/
    int perms;
+ 	/**
+ 	*/
    bool tryDowngrade;
  };
  
! /**
! *	This class ist used make file access operations easier.
! * It keeps a list of all open files internally and closes them
! * when the destructor is called.
! */
  class FileMgr
  {
***************
*** 62,79 ****
  public:
  
      FileMgr (int maxFiles = 35);
!    ~FileMgr ();
    FileDesc *open (const char *path, int mode, bool tryDowngrade);
    FileDesc *open (const char *path, int mode, int perms = S_IREAD | S_IWRITE, bool tryDowngrade = false);
-   void close (FileDesc *);
  
    static signed char existsFile (const char *ipath, const char *ifileName = 0);
    static signed char existsDir (const char *ipath, const char *idirName = 0);
-   // to truncate a file at its current position
-   // leaving byte at current possition intact
-   // deleting everything afterward.
-   signed char trunc (FileDesc *);
  
    int maxFiles;
    static FileMgr systemFileMgr;
  };
--- 80,139 ----
  public:
  
+ 	/** Constructor.
+ 	* @param maxFiles The number of files that this FileMgr may open in parallel, if necessary.
+ 	*/
      FileMgr (int maxFiles = 35);
!   /**
! 	* Destructor. Clean things up. Will close all files opened by this FileMgr object.
! 	*/
! 	 ~FileMgr ();
! 
! 	/** Open a file and return a FileDesc for it.
! 	* The file itself will only be opened when FileDesc::getFd() is called.
! 	* @param path Filename.
! 	* @param mode File access mode.
! 	* @param tryDowngrade
! 	* @return FileDesc object for the requested file.
! 	*/
    FileDesc *open (const char *path, int mode, bool tryDowngrade);
+ 	/** Open a file and return a FileDesc for it.
+ 	* The file itself will only be opened when FileDesc::getFd() is called.
+ 	* @param path Filename.
+ 	* @param mode File access mode.
+ 	* @param perms Permissions.
+ 	* @param tryDowngrade
+ 	* @return FileDesc object for the requested file.
+ 	*/
    FileDesc *open (const char *path, int mode, int perms = S_IREAD | S_IWRITE, bool tryDowngrade = false);
  
+   /** Close a given file and delete its FileDesc object.
+ 	* Will only close the file if it was created by this FileMgr object.
+ 	* @param file The file to close.
+ 	*/
+   void close (FileDesc * file);
+ 
+ 	/** Checks for the existence of a file.
+ 	* @param ipath Path to file.
+ 	* @param ifileName Name of file to check for.
+ 	*/
    static signed char existsFile (const char *ipath, const char *ifileName = 0);
+ 
+ 	/** Checks for the existence of a directory.
+ 	* @param ipath Path to directory.
+ 	* @param idirName Name of directory to check for.
+ 	*/
    static signed char existsDir (const char *ipath, const char *idirName = 0);
  
+   /** Truncate a file at its current position
+   * leaving byte at current possition intact deleting everything afterward.
+ 	* @param file The file to operate on.
+ 	*/
+   signed char trunc (FileDesc * file);
+ 
+ 	/** Maximum number of open files set in the constructor.
+ 	* Change this if you need to open more files.
+ 	*/
    int maxFiles;
+ 	
    static FileMgr systemFileMgr;
  };