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,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXFile.h,v 1.100 2006/01/22 17:58:01 fox Exp $                            *
00023 ********************************************************************************/
00024 #ifndef FXFILE_H
00025 #define FXFILE_H
00026 
00027 #ifndef FXIO_H
00028 #include "FXIO.h"
00029 #endif
00030 
00031 
00032 namespace FX {
00033 
00034 
00035 /**
00036 * Low level file access.
00037 */
00038 class FXAPI FXFile : public FXIO {
00039 private:
00040   FXFile(const FXFile&);
00041   FXFile &operator=(const FXFile&);
00042 public:
00043 
00044   /// Construct file
00045   FXFile(){ }
00046 
00047   /// Construct file and attach existing handle h
00048   FXFile(FXInputHandle handle,FXuint mode);
00049 
00050   /// Construct and open a file
00051   FXFile(const FXString& file,FXuint mode=FXIO::Reading,FXuint perm=FXIO::OwnerReadWrite|FXIO::GroupReadWrite|FXIO::OtherReadWrite);
00052 
00053   /// Open file
00054   virtual bool open(const FXString& file,FXuint mode=FXIO::Reading,FXuint perm=FXIO::OwnerReadWrite|FXIO::GroupReadWrite|FXIO::OtherReadWrite);
00055 
00056   /// Open device with access mode and handle
00057   virtual bool open(FXInputHandle handle,FXuint mode);
00058 
00059   /// Get current file position
00060   virtual FXlong position() const;
00061 
00062   /// Change file position, returning new position from start
00063   virtual FXlong position(FXlong offset,FXuint from=FXIO::Begin);
00064 
00065   /// Read block of bytes, returning number of bytes read
00066   virtual FXival readBlock(void* data,FXival count);
00067 
00068   /// Write block of bytes, returning number of bytes written
00069   virtual FXival writeBlock(const void* data,FXival count);
00070 
00071   /// Truncate file
00072   virtual FXlong truncate(FXlong size);
00073 
00074   /// Flush to disk
00075   virtual bool flush();
00076 
00077   /// Return file size
00078   virtual FXlong size();
00079 
00080   /// Test if we're at the end
00081   virtual bool eof();
00082 
00083   /// Close file
00084   virtual bool close();
00085 
00086 
00087   /// Create new (empty) file
00088   static bool create(const FXString& file,FXuint perm=FXIO::OwnerReadWrite|FXIO::GroupReadWrite|FXIO::OtherReadWrite);
00089 
00090   /// Remove file
00091   static bool remove(const FXString& file);
00092 
00093   /// Rename or move srcfile to dstfile, replacing dstfile if it exists
00094   static bool rename(const FXString& srcfile,const FXString& dstfile);
00095 
00096   /// Link file
00097   static bool link(const FXString& srcfile,const FXString& dstfile);
00098 
00099   /// Read symbolic link
00100   static FXString symlink(const FXString& file);
00101 
00102   /// Symbolic link file
00103   static bool symlink(const FXString& srcfile,const FXString& dstfile);
00104 
00105   /// Return true if files are identical
00106   static bool identical(const FXString& file1,const FXString& file2);
00107 
00108   /// Copy srcfile to dstfile, overwriting dstfile if allowed
00109   static bool copy(const FXString& srcfile,const FXString& dstfile,bool overwrite=false);
00110 
00111   /// Concatenate srcfile1 and srcfile2 to dstfile, overwriting dstfile if allowed
00112   static bool concat(const FXString& srcfile1,const FXString& srcfile2,const FXString& dstfile,bool overwrite=false);
00113 
00114 
00115 
00116   /// Recursively copy files or directories from srcfile to dstfile, overwriting dstfile if allowed
00117   static bool copyFiles(const FXString& srcfile,const FXString& dstfile,bool overwrite=false);
00118 
00119   /// Recursively copy or move files or directories from srcfile to dstfile, overwriting dstfile if allowed
00120   static bool moveFiles(const FXString& srcfile,const FXString& dstfile,bool overwrite=false);
00121 
00122   /// Recursively remove file or directory, recurse if allowed
00123   static bool removeFiles(const FXString& path,bool recursive=false);
00124 
00125   /// Destroy
00126   virtual ~FXFile();
00127   };
00128 
00129 }
00130 
00131 #endif

Copyright © 1997-2005 Jeroen van der Zijp