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

FXFile.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                             F i l e   C l a s s                               *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2000,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXFile.h,v 1.110 2009/01/06 13:07:23 fox Exp $                           *
00022 ********************************************************************************/
00023 #ifndef FXFILE_H
00024 #define FXFILE_H
00025 
00026 #ifndef FXIO_H
00027 #include "FXIO.h"
00028 #endif
00029 
00030 
00031 namespace FX {
00032 
00033 
00034 /**
00035 * Low level file access.
00036 */
00037 class FXAPI FXFile : public FXIO {
00038 private:
00039   FXFile(const FXFile&);
00040   FXFile &operator=(const FXFile&);
00041 public:
00042 
00043   /// Construct file
00044   FXFile(){ }
00045 
00046   /// Construct file and attach existing handle h
00047   FXFile(FXInputHandle h,FXuint m);
00048 
00049   /// Construct and open a file
00050   FXFile(const FXString& file,FXuint m=FXIO::Reading,FXuint perm=FXIO::AllReadWrite);
00051 
00052   /// Open file
00053   virtual FXbool open(const FXString& file,FXuint m=FXIO::Reading,FXuint perm=FXIO::AllReadWrite);
00054 
00055   /// Open device with access mode and handle
00056   virtual FXbool open(FXInputHandle h,FXuint m);
00057 
00058   /// Return true if serial access only
00059   virtual FXbool isSerial() const;
00060 
00061   /// Get current file position
00062   virtual FXlong position() const;
00063 
00064   /// Change file position, returning new position from start
00065   virtual FXlong position(FXlong offset,FXuint from=FXIO::Begin);
00066 
00067   /// Read block of bytes, returning number of bytes read
00068   virtual FXival readBlock(void* data,FXival count);
00069 
00070   /// Write block of bytes, returning number of bytes written
00071   virtual FXival writeBlock(const void* data,FXival count);
00072 
00073   /// Truncate file to size s
00074   virtual FXlong truncate(FXlong s);
00075 
00076   /// Flush to disk
00077   virtual FXbool flush();
00078 
00079   /// Return file size
00080   virtual FXlong size();
00081 
00082   /// Test if we're at the end
00083   virtual FXbool eof();
00084 
00085   /// Close file
00086   virtual FXbool close();
00087 
00088 
00089   /// Create new (empty) file
00090   static FXbool create(const FXString& file,FXuint perm=FXIO::AllReadWrite);
00091 
00092   /// Remove file
00093   static FXbool remove(const FXString& file);
00094 
00095   /// Rename or move srcfile to dstfile, replacing dstfile if it exists
00096   static FXbool rename(const FXString& srcfile,const FXString& dstfile);
00097 
00098   /// Link file
00099   static FXbool link(const FXString& srcfile,const FXString& dstfile);
00100 
00101   /// Read symbolic link
00102   static FXString symlink(const FXString& file);
00103 
00104   /// Symbolic link file
00105   static FXbool symlink(const FXString& srcfile,const FXString& dstfile);
00106 
00107   /// Return true if files are identical
00108   static FXbool identical(const FXString& file1,const FXString& file2);
00109 
00110   /// Copy srcfile to dstfile, overwriting dstfile if allowed
00111   static FXbool copy(const FXString& srcfile,const FXString& dstfile,FXbool overwrite=false);
00112 
00113   /// Concatenate srcfile1 and srcfile2 to dstfile, overwriting dstfile if allowed
00114   static FXbool concat(const FXString& srcfile1,const FXString& srcfile2,const FXString& dstfile,FXbool overwrite=false);
00115 
00116 
00117 
00118   /// Recursively copy files or directories from srcfile to dstfile, overwriting dstfile if allowed
00119   static FXbool copyFiles(const FXString& srcfile,const FXString& dstfile,FXbool overwrite=false);
00120 
00121   /// Recursively copy or move files or directories from srcfile to dstfile, overwriting dstfile if allowed
00122   static FXbool moveFiles(const FXString& srcfile,const FXString& dstfile,FXbool overwrite=false);
00123 
00124   /// Recursively remove file or directory, recurse if allowed
00125   static FXbool removeFiles(const FXString& path,FXbool recursive=false);
00126 
00127 
00128   /// Destroy
00129   virtual ~FXFile();
00130   };
00131 
00132 }
00133 
00134 #endif

Copyright © 1997-2009 Jeroen van der Zijp