PCL
File.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.5
6 // ----------------------------------------------------------------------------
7 // pcl/File.h - Released 2024-01-13T15:47:58Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_File_h
53 #define __PCL_File_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Diagnostics.h>
59 
60 #include <pcl/ByteArray.h>
61 #include <pcl/Exception.h>
62 #include <pcl/FileInfo.h>
63 #include <pcl/StringList.h>
64 
65 #ifndef __PCL_FILE_DONT_REMOVE_PREVIOUS_DECLARATION
66 
67 /*
68  * Remove conflicting identifiers from Win32 SDK headers.
69  */
70 
71 #ifdef CreateFile
72 #undef CreateFile
73 #endif
74 
75 #ifdef CopyFile
76 #undef CopyFile
77 #endif
78 
79 #ifdef MoveFile
80 #undef MoveFile
81 #endif
82 
83 #ifdef CreateDirectory
84 #undef CreateDirectory
85 #endif
86 
87 #ifdef RemoveDirectory
88 #undef RemoveDirectory
89 #endif
90 
91 #endif // !__PCL_FILE_DONT_REMOVE_PREVIOUS_DECLARATION
92 
93 namespace pcl
94 {
95 
96 // ----------------------------------------------------------------------------
97 
102 // ----------------------------------------------------------------------------
103 
122 namespace FileMode
123 {
124  enum mask_type
125  {
126  Zero = 0x00000000,
127 
128  /*
129  * Access mode
130  */
131  Read = 0x00000001,
132  Write = 0x00000002,
133  AccessMode = 0x0000000F,
134 
135  /*
136  * Share mode (Windows only)
137  */
138  ShareRead = 0x00000010,
139  ShareWrite = 0x00000020,
140  ShareMode = 0x000000F0,
141 
142  /*
143  * Open/create mode
144  */
145  Open = 0x00000100,
146  Create = 0x00000200,
147  OpenMode = 0x00000F00
148  };
149 }
150 
156 using FileModes = Flags<FileMode::mask_type>;
157 
158 // ----------------------------------------------------------------------------
159 
172 namespace SeekMode
173 {
174  enum value_type
175  {
176  FromBegin, // Move relative to the beginning of the file
177  FromCurrent, // Move from current position
178  FromEnd, // Move relative to the end of the file
179  NumberOfSeekModes
180  };
181 }
182 
183 // ----------------------------------------------------------------------------
184 
192 {
197  int userId;
198  int groupId;
202 
206  bool IsDirectory() const
207  {
208  return attributes.IsFlagSet( FileAttribute::Directory );
209  }
210 
215  bool IsArchive() const
216  {
217  return attributes.IsFlagSet( FileAttribute::Archive );
218  }
219 
224  bool IsCompressed() const
225  {
226  return attributes.IsFlagSet( FileAttribute::Compressed );
227  }
228 
233  bool IsEncrypted() const
234  {
235  return attributes.IsFlagSet( FileAttribute::Encrypted );
236  }
237 
242  bool IsHidden() const
243  {
244  return attributes.IsFlagSet( FileAttribute::Hidden );
245  }
246 
251  bool IsReadOnly() const
252  {
253  return attributes.IsFlagSet( FileAttribute::ReadOnly );
254  }
255 
260  bool IsSystem() const
261  {
262  return attributes.IsFlagSet( FileAttribute::System );
263  }
264 
269  bool IsTemporary() const
270  {
271  return attributes.IsFlagSet( FileAttribute::Temporary );
272  }
273 
277  bool IsEmpty() const
278  {
279  return size == 0;
280  }
281 };
282 
283 // ----------------------------------------------------------------------------
284 
299 namespace ReadTextOption
300 {
301  enum mask_type
302  {
303  RemoveEmptyLines = 0x0001,
304  TrimTrailingSpaces = 0x0002,
305  TrimLeadingSpaces = 0x0004,
306  TrimSpaces = TrimTrailingSpaces | TrimLeadingSpaces
307  };
308 }
309 
316 using ReadTextOptions = Flags<ReadTextOption::mask_type>;
317 
318 // ----------------------------------------------------------------------------
319 
328 {
329  bool exists = false;
330  bool overwrite = false;
331 };
332 
333 // ----------------------------------------------------------------------------
334 
343 class PCL_CLASS File
344 {
345 public:
346 
350  using handle = void*;
351 
355  using seek_mode = SeekMode::value_type;
356 
362  class PCL_CLASS Error : public pcl::Error
363  {
364  public:
365 
370  Error( const String& filePath, const String& message )
371  : pcl::Error( message )
372  , m_filePath( filePath )
373  {
374  }
375 
379  Error( const Error& ) = default;
380 
383  String ExceptionClass() const override
384  {
385  return "File I/O Error";
386  }
387 
391  virtual String FilePath() const
392  {
393  return m_filePath;
394  }
395 
398  virtual String ErrorMessage() const
399  {
400  return m_message;
401  }
402 
405  String Message() const override
406  {
407  String filePath = FilePath();
408  String message = m_message;
409  if ( !filePath.IsEmpty() )
410  {
411  message += ": ";
412  message += filePath;
413  }
414  return message;
415  }
416 
417  private:
418 
419  String m_filePath;
420  };
421 
458  class PCL_CLASS Find
459  {
460  public:
461 
465  Find() = default;
466 
474  Find( const String& path )
475  {
476  Begin( path );
477  }
478 
484  {
485  End();
486  }
487 
492  Find( const Find& ) = delete;
493 
498  Find& operator =( const Find& ) = delete;
499 
506  void Begin( const String& path );
507 
519  bool NextItem( FindFileInfo& info );
520 
525  void End();
526 
531  {
532  return m_searchPath;
533  }
534 
535  private:
536 
537  FindFileInfo m_info;
538  String m_searchPath;
539 #ifndef __PCL_WINDOWS
540  String m_searchDir;
541  String m_searchName;
542 #endif
543  void* m_handle = nullptr;
544  };
545 
559  class PCL_CLASS Progress
560  {
561  public:
562 
576  Progress( fsize_type total, const String& initialText = String(), fsize_type initialValue = 0 )
577  : m_total( Max( fsize_type( 0 ), total ) )
578  , m_current( Range( initialValue, fsize_type( 0 ), m_total ) )
579  , m_text( initialText )
580  {
581  }
582 
586  virtual ~Progress()
587  {
588  }
589 
594  {
595  return m_total;
596  }
597 
602  {
603  return m_current;
604  }
605 
609  const String& Text() const
610  {
611  return m_text;
612  }
613 
621  void SetValue( fsize_type current )
622  {
623  if ( current >= m_current )
624  {
625  m_current = current;
626 
627  if ( !ValueChanged() )
628  {
629  m_abort = true;
630  throw ProcessAborted();
631  }
632  }
633  }
634 
642  void Add( fsize_type delta )
643  {
644  if ( delta >= 0 )
645  {
646  m_current += delta;
647 
648  if ( !ValueChanged() )
649  {
650  m_abort = true;
651  throw ProcessAborted();
652  }
653  }
654  }
655 
663  void SetText( const String& text )
664  {
665  m_text = text;
666 
667  if ( !TextChanged() )
668  {
669  m_abort = true;
670  throw ProcessAborted();
671  }
672  }
673 
677  bool IsAborted() const
678  {
679  return m_abort;
680  }
681 
682  protected:
683 
684  fsize_type m_total;
685  fsize_type m_current;
686  String m_text;
687  bool m_abort = false;
688 
696  virtual bool ValueChanged() = 0;
697 
705  virtual bool TextChanged() = 0;
706  };
707 
708  // -------------------------------------------------------------------------
709 
714  {
715  Initialize();
716  }
717 
722  File( const String& path, FileModes mode )
723  {
724  PCL_PRECONDITION( !path.IsEmpty() )
725  Initialize();
726  Open( path, mode );
727  }
728 
732  File( File&& x )
733  : m_fileHandle( x.m_fileHandle )
734  , m_filePath( std::move( x.m_filePath ) )
735  , m_fileMode( x.m_fileMode )
736  {
737  x.m_fileHandle = s_invalidHandle;
738  x.m_fileMode = FileMode::Zero;
739  }
740 
744  File& operator =( File&& x )
745  {
746  if ( &x != this )
747  {
748  if ( IsOpen() )
749  Close();
750  m_fileHandle = x.m_fileHandle;
751  m_filePath = std::move( x.m_filePath );
752  m_fileMode = x.m_fileMode;
753  x.m_fileHandle = s_invalidHandle;
754  x.m_fileMode = FileMode::Zero;
755  }
756  return *this;
757  }
758 
763  virtual ~File()
764  {
765  if ( IsOpen() )
766  Close();
767  }
768 
773  File( const File& ) = delete;
774 
779  File& operator =( const File& ) = delete;
780 
784  bool IsOpen() const
785  {
786  return IsValidHandle( m_fileHandle );
787  }
788 
793  const String& FilePath() const
794  {
795  return m_filePath;
796  }
797 
804  const String& FileName() const
805  {
806  return FilePath();
807  }
808 
812  FileModes Mode() const
813  {
814  return m_fileMode;
815  }
816 
820  virtual bool CanRead() const
821  {
822  return m_fileMode.IsFlagSet( FileMode::Read );
823  }
824 
828  virtual bool CanWrite() const
829  {
830  return m_fileMode.IsFlagSet( FileMode::Write );
831  }
832 
837  virtual fpos_type Position() const;
838 
842  virtual void SetPosition( fpos_type pos );
843 
851  fpos_type Seek( fpos_type dist, seek_mode mode = SeekMode::FromCurrent );
852 
862  {
863  return Seek( 0, SeekMode::FromEnd );
864  }
865 
871  void Rewind()
872  {
873  SetPosition( 0 );
874  }
875 
880  bool IsEOF() const
881  {
882  return Position() >= Size();
883  }
884 
888  virtual fsize_type Size() const;
889 
893  virtual void Resize( fsize_type length );
894 
898  virtual void Read( void* buffer, fsize_type len );
899 
903  template <typename T>
904  void Read( T& x )
905  {
906  Read( (void*)&x, sizeof( T ) );
907  }
908 
916  template <typename T>
917  void ReadArray( T* a, size_type n )
918  {
919  Read( (void*)a, n*sizeof( T ) );
920  }
921 
925  template <typename T>
926  void ReadI32( T& x )
927  {
928  int32 i; Read( i ); x = T( i );
929  }
930 
934  template <typename T>
935  void ReadUI32( T& x )
936  {
937  uint32 i; Read( i ); x = T( i );
938  }
939 
943  template <typename T>
944  void ReadI64( T& x )
945  {
946  int64 i; Read( i ); x = T( i );
947  }
948 
952  template <typename T>
953  void ReadUI64( T& x )
954  {
955  uint64 i; Read( i ); x = T( i );
956  }
957 
961  virtual void Write( const void* buffer, fsize_type len );
962 
966  template <typename T>
967  void Write( const T& x )
968  {
969  Write( (const void*)&x, sizeof( T ) );
970  }
971 
979  template <typename T>
980  void WriteArray( const T* a, size_type n )
981  {
982  Write( (const void*)a, n*sizeof( T ) );
983  }
984 
988  template <typename T>
989  void WriteI32( const T& x )
990  {
991  Write( int32( x ) );
992  }
993 
997  template <typename T>
998  void WriteUI32( const T& x )
999  {
1000  Write( uint32( x ) );
1001  }
1002 
1006  template <typename T>
1007  void WriteI64( const T& x )
1008  {
1009  Write( int64( x ) );
1010  }
1011 
1015  template <typename T>
1016  void WriteUI64( const T& x )
1017  {
1018  Write( uint64( x ) );
1019  }
1020 
1027  void Read( bool& b )
1028  {
1029  unsigned i; ReadUI32( i ); b = i != 0;
1030  }
1031 
1038  void Write( const bool& b )
1039  {
1040  WriteUI32( b ? 1 : 0 );
1041  }
1042 
1048  void Read( IsoString& s );
1049 
1055  void Read( String& s );
1056 
1061  void Write( const char* i, const char* j );
1062 
1066  void Write( const char* s )
1067  {
1068  Write( s, s + IsoCharTraits::Length( s ) );
1069  }
1070 
1074  void Write( const IsoString& s )
1075  {
1076  Write( s.Begin(), s.End() );
1077  }
1078 
1083  void Write( const char16_type* i, const char16_type* j );
1084 
1088  void Write( const char16_type* s )
1089  {
1090  Write( s, s + CharTraits::Length( s ) );
1091  }
1092 
1096  void Write( const String& s )
1097  {
1098  Write( s.Begin(), s.End() );
1099  }
1100 
1101 #ifndef __PCL_NO_FLAGS_FILE_IO
1102 
1106  template <typename E>
1107  static void Read( Flags<E>& f )
1108  {
1109  Read( f.m_flags );
1110  }
1111 
1115  template <typename E>
1116  static void ReadUI32( Flags<E>& f )
1117  {
1118  ReadUI32( f.m_flags );
1119  }
1120 
1124  template <typename E>
1125  static void Write( Flags<E> f )
1126  {
1127  Write( f.m_flags );
1128  }
1129 
1133  template <typename E>
1134  static void WriteUI32( Flags<E> f )
1135  {
1136  WriteUI32( f.m_flags );
1137  }
1138 
1139 #endif
1140 
1145  void OutText( const char* i, const char* j )
1146  {
1147  if ( i < j )
1148  Write( (const void*)i, fsize_type( j - i ) );
1149  }
1150 
1154  void OutText( const char* s )
1155  {
1156  OutText( s, s + IsoCharTraits::Length( s ) );
1157  }
1158 
1162  void OutText( const IsoString& s )
1163  {
1164  OutText( s.Begin(), s.End() );
1165  }
1166 
1171  void OutText( const char16_type* i, const char16_type* j )
1172  {
1173  if ( i < j )
1174  Write( (const void*)i, fsize_type( j - i ) << 1 );
1175  }
1176 
1180  void OutText( const char16_type* s )
1181  {
1182  OutText( s, s + CharTraits::Length( s ) );
1183  }
1184 
1188  void OutText( const String& s )
1189  {
1190  OutText( s.Begin(), s.End() );
1191  }
1192 
1197  void OutTextLn( const char* i, const char* j )
1198  {
1199  OutText( i, j ); Write( '\n' );
1200  }
1201 
1206  void OutTextLn( const char* s )
1207  {
1208  OutText( s ); Write( '\n' );
1209  }
1210 
1222  void OutTextLn()
1223  {
1224  Write( '\n' );
1225  }
1226 
1231  void OutTextLn( const IsoString& s )
1232  {
1233  OutText( s ); Write( '\n' );
1234  }
1235 
1240  void OutTextLn( const char16_type* i, const char16_type* j )
1241  {
1242  OutText( i, j ); Write( char16_type( '\n' ) );
1243  }
1244 
1249  void OutTextLn( const char16_type* s )
1250  {
1251  OutText( s ); Write( char16_type( '\n' ) );
1252  }
1253 
1258  void OutTextLn( const String& s )
1259  {
1260  OutText( s ); Write( char16_type( '\n' ) );
1261  }
1262 
1266  void Flush();
1267 
1277  virtual void Open( const String& path, FileModes mode = FileMode::Read|FileMode::Open );
1278 
1284  virtual void OpenForReading( const String& path )
1285  {
1286  Open( path, FileMode::Read|FileMode::Open|FileMode::ShareRead );
1287  }
1288 
1295  static File OpenFileForReading( const String& path )
1296  {
1297  File f;
1298  f.OpenForReading( path );
1299  return f;
1300  }
1301 
1305  virtual void OpenForReadWrite( const String& path )
1306  {
1307  Open( path, FileMode::Read|FileMode::Write|FileMode::Open );
1308  }
1309 
1314  static File OpenFileForReadWrite( const String& path )
1315  {
1316  File f;
1317  f.OpenForReadWrite( path );
1318  return f;
1319  }
1320 
1326  virtual void Create( const String& path )
1327  {
1328  Open( path, FileMode::Read|FileMode::Write|FileMode::Create );
1329  }
1330 
1336  static File CreateFile( const String& path )
1337  {
1338  File f;
1339  f.Create( path );
1340  return f;
1341  }
1342 
1348  virtual void CreateForWriting( const String& path )
1349  {
1350  Open( path, FileMode::Write|FileMode::Create );
1351  }
1352 
1358  static File CreateFileForWriting( const String& path )
1359  {
1360  File f;
1361  f.CreateForWriting( path );
1362  return f;
1363  }
1364 
1369  void OpenOrCreate( const String& path )
1370  {
1371  Open( path, FileMode::Read|FileMode::Write|FileMode::Open|FileMode::Create );
1372  }
1373 
1378  static File OpenOrCreateFile( const String& path )
1379  {
1380  File f;
1381  f.OpenOrCreate( path );
1382  return f;
1383  }
1384 
1389  virtual void Close();
1390 
1394  static void Remove( const String& filePath );
1395 
1403  static void CreateDirectory( const String& dirPath, bool createIntermediateDirectories = true );
1404 
1410  static void RemoveDirectory( const String& dirPath );
1411 
1426  static void Move( const String& filePath, const String& newFilePath );
1427 
1431  static bool Exists( const String& filePath );
1432 
1436  static bool DirectoryExists( const String& dirPath );
1437 
1490  static UniqueFileChecks EnsureNewUniqueFile( String& filePath, bool canOverwrite = false );
1491 
1540  static UniqueFileChecks EnsureNewUniqueDirectory( String& dirPath );
1541 
1546  static bool IsReadOnly( const String& filePath );
1547 
1552  static void SetReadOnly( const String& filePath, bool rdOnly = true );
1553 
1561  static void SetReadWrite( const String& filePath )
1562  {
1563  SetReadOnly( filePath, false );
1564  }
1565 
1570  static ByteArray ReadFile( const String& filePath );
1571 
1593  static void WriteFile( const String& filePath, const ByteArray& contents );
1594 
1610  static void WriteFile( const String& filePath, const ByteArray& contents, size_type start, size_type size );
1611 
1626  static void WriteFile( const String& filePath, const void* data, size_type size );
1627 
1635  static IsoString ReadTextFile( const String& filePath );
1636 
1651  static void WriteTextFile( const String& filePath, const IsoString& text );
1652 
1668  static void SetPermissions( const String& targetPath, FileAttributes permissions );
1669 
1680  static void CopyTimesAndPermissions( const String& targetPath, const String& sourcePath );
1681 
1682 #ifndef __PCL_WINDOWS
1683 
1700  static void CopyLink( const String& targetLinkPath, const String& sourceLinkPath );
1701 #endif // !__PCL_WINDOWS
1702 
1736  static void CopyFile( const String& targetFilePath, const String& sourceFilePath, File::Progress* progress = nullptr );
1737 
1776  static void MoveFile( const String& targetFilePath, const String& sourceFilePath, File::Progress* progress = nullptr );
1777 
1791  static bool SameDevice( const String& path1, const String& path2 );
1792 
1811  static bool SameFile( const String& path1, const String& path2 );
1812 
1832  static IsoStringList ReadLines( const String& filePath,
1833  ReadTextOptions options = ReadTextOptions() );
1834 
1872  static size_type ScanLines( const String& filePath,
1873  bool (*callback)( char*, void* ), void* data = nullptr,
1874  ReadTextOptions options = ReadTextOptions() );
1875 
1879  static String FullPath( const String& path );
1880 
1910  static IsoString FileURI( const String& path );
1911 
1927  static String SystemTempDirectory();
1928 
1939  static String SystemCacheDirectory();
1940 
1955  static String HomeDirectory();
1956 
1961  static String WindowsPathToUnix( const String& path );
1962 
1967  static String UnixPathToWindows( const String& path );
1968 
1999  static String UniqueFileName( const String& directory = String(), int n = 12,
2000  const String& prefix = String(), const String& postfix = String() );
2001 
2024  static uint64 GetAvailableSpace( const String& dirPath, uint64* totalBytes = nullptr, uint64* freeBytes = nullptr );
2025 
2035  static size_type FindDrive( const String& path );
2036 
2045  static size_type FindName( const String& path );
2046 
2059  static size_type FindExtension( const String& path );
2060 
2064  static size_type FindSuffix( const String& path )
2065  {
2066  return FindExtension( path );
2067  }
2068 
2081  static size_type FindCompleteSuffix( const String& path );
2082 
2092  static String ExtractDrive( const String& path ); // always empty string on X
2093 
2108  static String ExtractDirectory( const String& path );
2109 
2121  static String ExtractName( const String& path );
2122 
2136  static String ExtractExtension( const String& path );
2137 
2141  static String ExtractSuffix( const String& path )
2142  {
2143  return ExtractExtension( path );
2144  }
2145 
2159  static String ExtractCompleteSuffix( const String& path );
2160 
2167  static String ExtractNameAndExtension( const String& path );
2168 
2172  static String ExtractNameAndSuffix( const String& path )
2173  {
2174  return ExtractNameAndExtension( path );
2175  }
2176 
2188  static String ChangeExtension( const String& filePath, const String& ext );
2189 
2194  static String AppendToName( const String& filePath, const String& postfix );
2195 
2200  static String PrependToName( const String& filePath, const String& prefix );
2201 
2226  static String SizeAsString( fsize_type sizeInBytes, int precision = 3, bool alsoShowBytes = false );
2227 
2228 protected:
2229 
2230  handle m_fileHandle;
2231  String m_filePath;
2232  FileModes m_fileMode;
2233 
2234  static const handle s_invalidHandle;
2235 
2236  void Initialize();
2237  virtual bool IsValidHandle( handle h ) const;
2238 };
2239 
2240 // ----------------------------------------------------------------------------
2241 
2242 } // pcl
2243 
2244 #endif // __PCL_File_h
2245 
2246 // ----------------------------------------------------------------------------
2247 // EOF pcl/File.h - Released 2024-01-13T15:47:58Z
pcl::File::IsEOF
bool IsEOF() const
Definition: File.h:880
pcl::FindFileInfo::IsCompressed
bool IsCompressed() const
Definition: File.h:224
pcl
PCL root namespace.
Definition: AbstractImage.h:76
pcl::FileTime
File date and time.
Definition: FileInfo.h:171
pcl::File::Progress::Progress
Progress(fsize_type total, const String &initialText=String(), fsize_type initialValue=0)
Definition: File.h:576
pcl::File::WriteUI32
void WriteUI32(const T &x)
Definition: File.h:998
pcl::File::Error::FilePath
virtual String FilePath() const
Definition: File.h:391
pcl::File::Write
void Write(const char16_type *s)
Definition: File.h:1088
FileInfo.h
pcl::FindFileInfo::attributes
FileAttributes attributes
Item attributes.
Definition: File.h:194
pcl::Range
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
Definition: Utility.h:190
pcl::File::CreateFile
static File CreateFile(const String &path)
Definition: File.h:1336
pcl::File::OpenForReading
virtual void OpenForReading(const String &path)
Definition: File.h:1284
pcl::File::OutText
void OutText(const char *s)
Definition: File.h:1154
pcl::File::WriteUI64
void WriteUI64(const T &x)
Definition: File.h:1016
pcl::File::Write
void Write(const IsoString &s)
Definition: File.h:1074
pcl::File::Find
Directory search operation.
Definition: File.h:458
pcl::File::OutTextLn
void OutTextLn(const IsoString &s)
Definition: File.h:1231
pcl::FindFileInfo::IsDirectory
bool IsDirectory() const
Definition: File.h:206
pcl::File::OutTextLn
void OutTextLn()
Definition: File.h:1222
pcl::File::Progress::~Progress
virtual ~Progress()
Definition: File.h:586
pcl::File::OpenOrCreate
void OpenOrCreate(const String &path)
Definition: File.h:1369
pcl::File::Error
File I/O exception.
Definition: File.h:362
pcl::IsoCharTraits::Length
static constexpr size_type Length(const char_type *__restrict__ s) noexcept
Definition: CharTraits.h:879
pcl::File::Progress::SetValue
void SetValue(fsize_type current)
Definition: File.h:621
pcl::File::OutTextLn
void OutTextLn(const char16_type *i, const char16_type *j)
Definition: File.h:1240
pcl::File::handle
void * handle
Definition: File.h:350
pcl::String
Unicode (UTF-16) string.
Definition: String.h:8112
pcl::File::Progress::Add
void Add(fsize_type delta)
Definition: File.h:642
pcl::Position
Reduction of planetary and stellar positions.
Definition: Position.h:345
pcl::Max
constexpr const T & Max(const T &a, const T &b) noexcept
Definition: Utility.h:119
pcl::File::FindSuffix
static size_type FindSuffix(const String &path)
Definition: File.h:2064
pcl::File::Mode
FileModes Mode() const
Definition: File.h:812
pcl::File::OpenForReadWrite
virtual void OpenForReadWrite(const String &path)
Definition: File.h:1305
pcl::File::Read
static void Read(Flags< E > &f)
Definition: File.h:1107
pcl::File::IsOpen
bool IsOpen() const
Definition: File.h:784
pcl::File::Progress
Abstract base class of file progress objects.
Definition: File.h:559
pcl::File::ReadArray
void ReadArray(T *a, size_type n)
Definition: File.h:917
pcl::File::Progress::IsAborted
bool IsAborted() const
Definition: File.h:677
pcl::IsoString
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5424
pcl::File::ReadI32
void ReadI32(T &x)
Definition: File.h:926
pcl::File::Progress::Value
fsize_type Value() const
Definition: File.h:601
pcl::uint32
unsigned int uint32
Definition: Defs.h:669
pcl::FindFileInfo
File information structure used by File::Find
Definition: File.h:191
pcl::File
A platform-independent interface to the local file system.
Definition: File.h:343
pcl::File::Error::Error
Error(const String &filePath, const String &message)
Definition: File.h:370
pcl::File::Progress::Total
fsize_type Total() const
Definition: File.h:593
pcl::File::CreateForWriting
virtual void CreateForWriting(const String &path)
Definition: File.h:1348
pcl::File::Read
void Read(bool &b)
Definition: File.h:1027
pcl::File::Write
void Write(const char *s)
Definition: File.h:1066
pcl::GenericString::Begin
iterator Begin()
Definition: String.h:976
pcl::File::SetReadWrite
static void SetReadWrite(const String &filePath)
Definition: File.h:1561
pcl::File::WriteI64
void WriteI64(const T &x)
Definition: File.h:1007
ReadTextOptions
A combination of file text reading mode flags.
pcl::File::File
File(File &&x)
Definition: File.h:732
pcl::File::Progress::Text
const String & Text() const
Definition: File.h:609
pcl::File::WriteUI32
static void WriteUI32(Flags< E > f)
Definition: File.h:1134
pcl::Flags::IsFlagSet
constexpr bool IsFlagSet(enum_type e) const
Definition: Flags.h:244
pcl::File::OpenFileForReadWrite
static File OpenFileForReadWrite(const String &path)
Definition: File.h:1314
Exception.h
pcl::File::CanWrite
virtual bool CanWrite() const
Definition: File.h:828
pcl::GenericString::End
iterator End()
Definition: String.h:1006
pcl::FindFileInfo::IsArchive
bool IsArchive() const
Definition: File.h:215
pcl::File::Write
void Write(const String &s)
Definition: File.h:1096
pcl::File::FilePath
const String & FilePath() const
Definition: File.h:793
pcl::GenericString::IsEmpty
bool IsEmpty() const noexcept
Definition: String.h:818
pcl::File::OpenOrCreateFile
static File OpenOrCreateFile(const String &path)
Definition: File.h:1378
pcl::size_type
size_t size_type
Definition: Defs.h:612
pcl::File::Error::Message
String Message() const override
Definition: File.h:405
pcl::File::WriteArray
void WriteArray(const T *a, size_type n)
Definition: File.h:980
pcl::Error
A simple exception with an associated error message.
Definition: Exception.h:238
pcl::Flags< FileAttribute::mask_type >
pcl::uint64
unsigned long long uint64
Definition: Defs.h:685
pcl::File::CreateFileForWriting
static File CreateFileForWriting(const String &path)
Definition: File.h:1358
FileModes
A combination of file access, share and opening/creation mode flags.
pcl::Array< uint8 >
pcl::File::Rewind
void Rewind()
Definition: File.h:871
pcl::File::Write
void Write(const T &x)
Definition: File.h:967
pcl::File::OutText
void OutText(const char16_type *s)
Definition: File.h:1180
pcl::FindFileInfo::IsTemporary
bool IsTemporary() const
Definition: File.h:269
pcl::FindFileInfo::IsHidden
bool IsHidden() const
Definition: File.h:242
pcl::File::Create
virtual void Create(const String &path)
Definition: File.h:1326
pcl::File::OutTextLn
void OutTextLn(const char *s)
Definition: File.h:1206
pcl::File::Read
void Read(T &x)
Definition: File.h:904
pcl::FindFileInfo::IsSystem
bool IsSystem() const
Definition: File.h:260
pcl::UniqueFileChecks
A simple POD structure to hold file uniqueness and overwrite verification results.
Definition: File.h:327
StringList.h
pcl::FindFileInfo::IsEmpty
bool IsEmpty() const
Definition: File.h:277
pcl::File::OpenFileForReading
static File OpenFileForReading(const String &path)
Definition: File.h:1295
pcl::File::ExtractNameAndSuffix
static String ExtractNameAndSuffix(const String &path)
Definition: File.h:2172
pcl::File::Find::SearchPath
String SearchPath() const
Definition: File.h:530
pcl::File::Find::Find
Find(const String &path)
Definition: File.h:474
pcl::File::ReadUI32
static void ReadUI32(Flags< E > &f)
Definition: File.h:1116
pcl::FindFileInfo::userId
int userId
User id of the file owner.
Definition: File.h:197
pcl::File::Find::~Find
~Find()
Definition: File.h:483
pcl::File::~File
virtual ~File()
Definition: File.h:763
pcl::File::ReadI64
void ReadI64(T &x)
Definition: File.h:944
ByteArray.h
pcl::FindFileInfo::name
String name
File or directory name, including the file name extension.
Definition: File.h:193
pcl::fsize_type
int64 fsize_type
Definition: Defs.h:1188
pcl::File::OutTextLn
void OutTextLn(const String &s)
Definition: File.h:1258
pcl::File::OutTextLn
void OutTextLn(const char *i, const char *j)
Definition: File.h:1197
pcl::File::File
File(const String &path, FileModes mode)
Definition: File.h:722
pcl::FindFileInfo::IsEncrypted
bool IsEncrypted() const
Definition: File.h:233
pcl::File::OutText
void OutText(const String &s)
Definition: File.h:1188
pcl::File::SeekEnd
fpos_type SeekEnd()
Definition: File.h:861
pcl::FindFileInfo::lastModified
FileTime lastModified
Time of last change.
Definition: File.h:201
pcl::int32
signed int int32
Definition: Defs.h:663
pcl::FindFileInfo::numberOfLinks
int numberOfLinks
Number of existing hard links to this file.
Definition: File.h:196
pcl::File::File
File()
Definition: File.h:713
pcl::File::FileName
const String & FileName() const
Definition: File.h:804
pcl::File::Error::ExceptionClass
String ExceptionClass() const override
Definition: File.h:383
pcl::File::Progress::SetText
void SetText(const String &text)
Definition: File.h:663
pcl::FindFileInfo::groupId
int groupId
Group id of the file owner.
Definition: File.h:198
pcl::File::ReadUI32
void ReadUI32(T &x)
Definition: File.h:935
pcl::CharTraits::Length
static size_type Length(const char_type *__restrict__ s) noexcept
Definition: CharTraits.h:1139
pcl::File::OutTextLn
void OutTextLn(const char16_type *s)
Definition: File.h:1249
pcl::File::OutText
void OutText(const char16_type *i, const char16_type *j)
Definition: File.h:1171
pcl::FindFileInfo::size
fsize_type size
File size in bytes.
Definition: File.h:195
pcl::fpos_type
int64 fpos_type
Definition: Defs.h:1182
pcl::File::ReadUI64
void ReadUI64(T &x)
Definition: File.h:953
pcl::File::CanRead
virtual bool CanRead() const
Definition: File.h:820
pcl::File::Write
static void Write(Flags< E > f)
Definition: File.h:1125
pcl::File::OutText
void OutText(const IsoString &s)
Definition: File.h:1162
pcl::File::WriteI32
void WriteI32(const T &x)
Definition: File.h:989
ProcessAborted
An exception class signaling the interruption of a process.
pcl::File::OutText
void OutText(const char *i, const char *j)
Definition: File.h:1145
pcl::int64
signed long long int64
Definition: Defs.h:679
pcl::FindFileInfo::IsReadOnly
bool IsReadOnly() const
Definition: File.h:251
Defs.h
pcl::FindFileInfo::created
FileTime created
Creation time.
Definition: File.h:199
pcl::File::Write
void Write(const bool &b)
Definition: File.h:1038
pcl::char16_type
uint16 char16_type
Definition: Defs.h:1144
pcl::File::ExtractSuffix
static String ExtractSuffix(const String &path)
Definition: File.h:2141
pcl::FindFileInfo::lastAccessed
FileTime lastAccessed
Time of last access.
Definition: File.h:200