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

FXFile.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * F i l e C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2000,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXFile.h,v 1.100 2006/01/22 17:58:01 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXFILE_H
25 #define FXFILE_H
26 
27 #ifndef FXIO_H
28 #include "FXIO.h"
29 #endif
30 
31 
32 namespace FX {
33 
34 
35 /**
36 * Low level file access.
37 */
38 class FXAPI FXFile : public FXIO {
39 private:
40  FXFile(const FXFile&);
41  FXFile &operator=(const FXFile&);
42 public:
43 
44  /// Construct file
45  FXFile(){ }
46 
47  /// Construct file and attach existing handle h
48  FXFile(FXInputHandle handle,FXuint mode);
49 
50  /// Construct and open a file
52 
53  /// Open file
55 
56  /// Open device with access mode and handle
57  virtual bool open(FXInputHandle handle,FXuint mode);
58 
59  /// Get current file position
60  virtual FXlong position() const;
61 
62  /// Change file position, returning new position from start
63  virtual FXlong position(FXlong offset,FXuint from=FXIO::Begin);
64 
65  /// Read block of bytes, returning number of bytes read
66  virtual FXival readBlock(void* data,FXival count);
67 
68  /// Write block of bytes, returning number of bytes written
69  virtual FXival writeBlock(const void* data,FXival count);
70 
71  /// Truncate file
72  virtual FXlong truncate(FXlong size);
73 
74  /// Flush to disk
75  virtual bool flush();
76 
77  /// Return file size
78  virtual FXlong size();
79 
80  /// Test if we're at the end
81  virtual bool eof();
82 
83  /// Close file
84  virtual bool close();
85 
86 
87  /// Create new (empty) file
89 
90  /// Remove file
91  static bool remove(const FXString& file);
92 
93  /// Rename or move srcfile to dstfile, replacing dstfile if it exists
94  static bool rename(const FXString& srcfile,const FXString& dstfile);
95 
96  /// Link file
97  static bool link(const FXString& srcfile,const FXString& dstfile);
98 
99  /// Read symbolic link
100  static FXString symlink(const FXString& file);
101 
102  /// Symbolic link file
103  static bool symlink(const FXString& srcfile,const FXString& dstfile);
104 
105  /// Return true if files are identical
106  static bool identical(const FXString& file1,const FXString& file2);
107 
108  /// Copy srcfile to dstfile, overwriting dstfile if allowed
109  static bool copy(const FXString& srcfile,const FXString& dstfile,bool overwrite=false);
110 
111  /// Concatenate srcfile1 and srcfile2 to dstfile, overwriting dstfile if allowed
112  static bool concat(const FXString& srcfile1,const FXString& srcfile2,const FXString& dstfile,bool overwrite=false);
113 
114 
115 
116  /// Recursively copy files or directories from srcfile to dstfile, overwriting dstfile if allowed
117  static bool copyFiles(const FXString& srcfile,const FXString& dstfile,bool overwrite=false);
118 
119  /// Recursively copy or move files or directories from srcfile to dstfile, overwriting dstfile if allowed
120  static bool moveFiles(const FXString& srcfile,const FXString& dstfile,bool overwrite=false);
121 
122  /// Recursively remove file or directory, recurse if allowed
123  static bool removeFiles(const FXString& path,bool recursive=false);
124 
125  /// Destroy
126  virtual ~FXFile();
127  };
128 
129 }
130 
131 #endif
unsigned int FXuint
Definition: fxdefs.h:396
Others have read and write permission.
Definition: FXIO.h:47
#define FXAPI
Definition: fxdefs.h:122
long FXival
Definition: fxdefs.h:435
Definition: FX4Splitter.h:31
Group has read and write permission.
Definition: FXIO.h:53
FXint FXInputHandle
Definition: fxdefs.h:468
Owner has read and write permission.
Definition: FXIO.h:59
Normal options for reading.
Definition: FXIO.h:95
Position from the begin (default)
Definition: FXIO.h:101
Low level file access.
Definition: FXFile.h:38
FXIO manipulates a handle to an abstract i/o device.
Definition: FXIO.h:37
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp