00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_FILE_SYSTEM_MANAGER_H_
00028 #define CEYLAN_FILE_SYSTEM_MANAGER_H_
00029
00030
00031
00032 #include "CeylanSystem.h"
00033 #include "CeylanStringUtils.h"
00034 #include "CeylanFileSystemCommon.h"
00035 #include "CeylanFile.h"
00036
00037
00038 #include <string>
00039
00040
00041
00042
00043 namespace Ceylan
00044 {
00045
00046
00047
00048 namespace System
00049 {
00050
00051
00052
00053
00054 class Directory ;
00055
00056
00057
00059 class CEYLAN_DLL FileSystemManagerException: public FileSystemException
00060 {
00061
00062 public:
00063
00064 explicit FileSystemManagerException(
00065 const std::string & reason ) :
00066 FileSystemException( reason )
00067 {
00068
00069 }
00070
00071 } ;
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 class CEYLAN_DLL EntryLookupFailed: public FileSystemManagerException
00084 {
00085
00086 public:
00087
00088 explicit EntryLookupFailed( const std::string & reason ) :
00089 FileSystemManagerException( reason )
00090 {
00091
00092 }
00093
00094 } ;
00095
00096
00097
00098 class CEYLAN_DLL SymlinkFailed: public FileSystemManagerException
00099 {
00100
00101 public:
00102
00103 explicit SymlinkFailed( const std::string & reason ) :
00104 FileSystemManagerException( reason )
00105 {
00106
00107 }
00108
00109 } ;
00110
00111
00112
00113 class CEYLAN_DLL GetChangeTimeFailed: public FileSystemManagerException
00114 {
00115
00116 public:
00117
00118 explicit GetChangeTimeFailed( const std::string & reason ) :
00119 FileSystemManagerException( reason )
00120 {
00121
00122 }
00123
00124 } ;
00125
00126
00127
00128 class CEYLAN_DLL FileSystemManagerDelegatingException:
00129 public FileSystemManagerException
00130 {
00131
00132 public:
00133
00134 explicit FileSystemManagerDelegatingException(
00135 const std::string & reason ) :
00136 FileSystemManagerException( reason )
00137 {
00138
00139 }
00140
00141 } ;
00142
00143
00144
00145
00146
00158 class CEYLAN_DLL FileSystemManager: public TextDisplayable
00159 {
00160
00161
00162 public:
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00201 static bool ExistsAsEntry( const std::string & entryPath ) ;
00202
00203
00204
00222 static void CreateSymbolicLink( const std::string & linkTarget,
00223 const std::string & linkName ) ;
00224
00225
00226
00242 static time_t GetEntryChangeTime(
00243 const std::string & entryPath ) ;
00244
00245
00246
00247
00248
00249
00250
00263 static const std::string & GetRootDirectoryPrefix() ;
00264
00265
00266
00279 static Ceylan::Latin1Char GetSeparator() ;
00280
00281
00282
00297 static std::string GetSeparatorAsString() ;
00298
00299
00300
00314 static const std::string & GetAliasForCurrentDirectory() ;
00315
00316
00317
00331 static const std::string & GetAliasForParentDirectory() ;
00332
00333
00334
00335
00336
00337
00338
00339
00340
00353 virtual bool existsAsEntry( const std::string & entryPath )
00354 const = 0 ;
00355
00356
00357
00370 virtual void createSymbolicLink( const std::string & linkTarget,
00371 const std::string & linkName ) = 0 ;
00372
00373
00374
00385 virtual time_t getEntryChangeTime(
00386 const std::string & entryPath ) = 0 ;
00387
00388
00389
00390
00391
00392
00393
00400 virtual const std::string & getRootDirectoryPrefix()
00401 const = 0 ;
00402
00403
00404
00411 virtual Ceylan::Latin1Char getSeparator() const = 0 ;
00412
00413
00414
00423 virtual std::string getSeparatorAsString() const ;
00424
00425
00426
00434 virtual const std::string & getAliasForCurrentDirectory()
00435 const ;
00436
00437
00438
00446 virtual const std::string & getAliasForParentDirectory()
00447 const ;
00448
00449
00450
00451
00452
00453
00454
00455
00456
00483 virtual File & createFile( const std::string & filename,
00484 OpeningFlag createFlag = File::CreateToWriteBinary,
00485 PermissionFlag permissionFlag = File::OwnerReadWrite ) = 0 ;
00486
00487
00488
00508 virtual File & openFile( const std::string & filename,
00509 OpeningFlag openFlag = File::OpenToReadBinary ) = 0 ;
00510
00511
00512
00527 virtual bool existsAsFileOrSymbolicLink(
00528 const std::string & filename ) const = 0 ;
00529
00530
00531
00541 virtual void removeFile( const std::string & filename ) = 0 ;
00542
00543
00544
00558 virtual void moveFile( const std::string & sourceFilename,
00559 const std::string & targetFilename ) = 0 ;
00560
00561
00562
00574 virtual void copyFile( const std::string & sourceFilename,
00575 const std::string & targetFilename ) = 0 ;
00576
00577
00578
00588 virtual Size getSize( const std::string & filename ) = 0 ;
00589
00590
00591
00602 virtual time_t getLastChangeTimeFile(
00603 const std::string & filename ) = 0 ;
00604
00605
00606
00617 virtual std::string transformIntoValidFilename(
00618 const std::string & rawFilename ) ;
00619
00620
00621
00641 virtual void touch( const std::string & filename ) = 0 ;
00642
00643
00644
00662 virtual bool diff( const std::string & firstFilename,
00663 const std::string & secondFilename ) ;
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00691 virtual Directory & createDirectory(
00692 const std::string & newDirectoryName ) = 0 ;
00693
00694
00695
00713 virtual Directory & openDirectory(
00714 const std::string & directoryName = "" ) = 0 ;
00715
00716
00717
00733 virtual bool existsAsDirectory(
00734 const std::string & directoryPath ) const = 0 ;
00735
00736
00737
00753 virtual void removeDirectory( const std::string & directoryPath,
00754 bool recursive = false ) = 0 ;
00755
00756
00757
00772 virtual void moveDirectory(
00773 const std::string & sourceDirectoryPath,
00774 const std::string & targetDirectoryPath ) = 0 ;
00775
00776
00777
00790 virtual void copyDirectory(
00791 const std::string & sourceDirectoryPath,
00792 const std::string & targetDirectoryPath ) = 0 ;
00793
00794
00795
00806 virtual time_t getLastChangeTimeDirectory(
00807 const std::string & directoryPath ) = 0 ;
00808
00809
00810
00822 virtual bool isAValidDirectoryPath(
00823 const std::string & directoryString ) = 0 ;
00824
00825
00826
00834 virtual void removeLeadingSeparator( std::string & path ) ;
00835
00836
00837
00844 virtual bool isAbsolutePath( const std::string & path ) = 0 ;
00845
00846
00847
00855 virtual std::string getCurrentWorkingDirectoryPath() = 0 ;
00856
00857
00858
00869 virtual void changeWorkingDirectory(
00870 const std::string & newWorkingDirectory )= 0 ;
00871
00872
00873
00874
00875
00876
00877
00878
00879
00893 virtual std::list<std::string> splitPath(
00894 const std::string & path ) ;
00895
00896
00897
00912 virtual std::string joinPath(
00913 const std::list<std::string> & pathElements ) ;
00914
00915
00916
00933 virtual std::string joinPath( const std::string & firstPath,
00934 const std::string & secondPath ) ;
00935
00936
00937
00959 virtual void stripFilename( const std::string & path,
00960 std::string * base, std::string * file = 0 ) ;
00961
00962
00963
00964
00965
00966
00967
00979 virtual const std::string toString(
00980 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01010 static bool IsDefaultFileSystemManagerSet() ;
01011
01012
01013
01023 static void SetDefaultFileSystemManager(
01024 FileSystemManager & newDefaultFileSystemManager,
01025 bool deallocatePreviousIfAny = true ) ;
01026
01027
01028
01046 static void SetDefaultFileSystemManagerToPlatformDefault() ;
01047
01048
01049
01060 static FileSystemManager &
01061 GetExistingDefaultFileSystemManager() ;
01062
01063
01064
01088 static FileSystemManager & GetAnyDefaultFileSystemManager() ;
01089
01090
01091
01096 static void RemoveDefaultFileSystemManager() ;
01097
01098
01099
01100
01101 protected:
01102
01103
01104
01114 FileSystemManager() ;
01115
01116
01117
01125 virtual ~FileSystemManager() throw() ;
01126
01127
01128
01146 static FileSystemManager * _CurrentDefaultFileSystemManager ;
01147
01148
01149
01150
01151 private:
01152
01153
01160 static const std::string DefaultAliasForCurrentDirectory ;
01161
01162
01169 static const std::string DefaultAliasForParentDirectory ;
01170
01171
01172
01181 FileSystemManager( const FileSystemManager & source ) ;
01182
01183
01184
01193 FileSystemManager & operator = (
01194 const FileSystemManager & source ) ;
01195
01196
01197
01198 } ;
01199
01200
01201 }
01202
01203 }
01204
01205
01206
01207
01208 #endif // CEYLAN_FILE_SYSTEM_MANAGER_H_
01209