PCL
|
A platform-independent interface to the local file system. More...
#include <File.h>
Classes | |
class | Error |
File I/O exception. More... | |
class | Find |
Directory search operation. More... | |
class | Progress |
Abstract base class of file progress objects. More... | |
Public Types | |
typedef void * | handle |
typedef SeekMode::value_type | seek_mode |
Public Member Functions | |
File () | |
File (const String &path, FileModes mode) | |
File (File &&x) | |
File (const File &)=delete | |
virtual | ~File () |
virtual bool | CanRead () const |
virtual bool | CanWrite () const |
virtual void | Close () |
virtual void | Create (const String &path) |
virtual void | CreateForWriting (const String &path) |
const String & | FileName () const |
const String & | FilePath () const |
void | Flush () |
bool | IsEOF () const |
bool | IsOpen () const |
FileModes | Mode () const |
virtual void | Open (const String &path, FileModes mode=FileMode::Read|FileMode::Open) |
virtual void | OpenForReading (const String &path) |
virtual void | OpenForReadWrite (const String &path) |
void | OpenOrCreate (const String &path) |
File & | operator= (File &&x) |
File & | operator= (const File &)=delete |
void | OutText (const char *i, const char *j) |
void | OutText (const char *s) |
void | OutText (const IsoString &s) |
void | OutText (const char16_type *i, const char16_type *j) |
void | OutText (const char16_type *s) |
void | OutText (const String &s) |
void | OutTextLn (const char *i, const char *j) |
void | OutTextLn (const char *s) |
void | OutTextLn () |
void | OutTextLn (const IsoString &s) |
void | OutTextLn (const char16_type *i, const char16_type *j) |
void | OutTextLn (const char16_type *s) |
void | OutTextLn (const String &s) |
virtual fpos_type | Position () const |
virtual void | Read (void *buffer, fsize_type len) |
template<typename T > | |
void | Read (T &x) |
void | Read (bool &b) |
void | Read (IsoString &s) |
void | Read (String &s) |
template<typename T > | |
void | ReadArray (T *a, size_type n) |
template<typename T > | |
void | ReadI32 (T &x) |
template<typename T > | |
void | ReadI64 (T &x) |
template<typename T > | |
void | ReadUI32 (T &x) |
template<typename T > | |
void | ReadUI64 (T &x) |
virtual void | Resize (fsize_type length) |
void | Rewind () |
fpos_type | Seek (fpos_type dist, seek_mode mode=SeekMode::FromCurrent) |
fpos_type | SeekEnd () |
virtual void | SetPosition (fpos_type pos) |
virtual fsize_type | Size () const |
virtual void | Write (const void *buffer, fsize_type len) |
template<typename T > | |
void | Write (const T &x) |
void | Write (const bool &b) |
void | Write (const char *i, const char *j) |
void | Write (const char *s) |
void | Write (const IsoString &s) |
void | Write (const char16_type *i, const char16_type *j) |
void | Write (const char16_type *s) |
void | Write (const String &s) |
template<typename T > | |
void | WriteArray (const T *a, size_type n) |
template<typename T > | |
void | WriteI32 (const T &x) |
template<typename T > | |
void | WriteI64 (const T &x) |
template<typename T > | |
void | WriteUI32 (const T &x) |
template<typename T > | |
void | WriteUI64 (const T &x) |
Static Public Member Functions | |
static String | AppendToName (const String &filePath, const String &postfix) |
static String | ChangeExtension (const String &filePath, const String &ext) |
static void | CopyFile (const String &targetFilePath, const String &sourceFilePath, File::Progress *progress=nullptr) |
static void | CopyLink (const String &targetLinkPath, const String &sourceLinkPath) |
static void | CopyTimesAndPermissions (const String &targetPath, const String &sourcePath) |
static void | CreateDirectory (const String &dirPath, bool createIntermediateDirectories=true) |
static File | CreateFile (const String &path) |
static File | CreateFileForWriting (const String &path) |
static bool | DirectoryExists (const String &dirPath) |
static bool | Exists (const String &filePath) |
static String | ExtractCompleteSuffix (const String &path) |
static String | ExtractDirectory (const String &path) |
static String | ExtractDrive (const String &path) |
static String | ExtractExtension (const String &path) |
static String | ExtractName (const String &path) |
static String | ExtractNameAndExtension (const String &path) |
static String | ExtractNameAndSuffix (const String &path) |
static String | ExtractSuffix (const String &path) |
static IsoString | FileURI (const String &path) |
static size_type | FindCompleteSuffix (const String &path) |
static size_type | FindDrive (const String &path) |
static size_type | FindExtension (const String &path) |
static size_type | FindName (const String &path) |
static size_type | FindSuffix (const String &path) |
static String | FullPath (const String &path) |
static uint64 | GetAvailableSpace (const String &dirPath, uint64 *totalBytes=nullptr, uint64 *freeBytes=nullptr) |
static String | HomeDirectory () |
static bool | IsReadOnly (const String &filePath) |
static void | Move (const String &filePath, const String &newFilePath) |
static void | MoveFile (const String &targetFilePath, const String &sourceFilePath, File::Progress *progress=nullptr) |
static File | OpenFileForReading (const String &path) |
static File | OpenFileForReadWrite (const String &path) |
static File | OpenOrCreateFile (const String &path) |
static String | PrependToName (const String &filePath, const String &prefix) |
template<typename E > | |
static void | Read (Flags< E > &f) |
static ByteArray | ReadFile (const String &filePath) |
static IsoStringList | ReadLines (const String &filePath, ReadTextOptions options=ReadTextOptions()) |
static IsoString | ReadTextFile (const String &filePath) |
template<typename E > | |
static void | ReadUI32 (Flags< E > &f) |
static void | Remove (const String &filePath) |
static void | RemoveDirectory (const String &dirPath) |
static bool | SameDevice (const String &path1, const String &path2) |
static bool | SameFile (const String &path1, const String &path2) |
static size_type | ScanLines (const String &filePath, bool(*callback)(char *, void *), void *data=nullptr, ReadTextOptions options=ReadTextOptions()) |
static void | SetPermissions (const String &targetPath, FileAttributes permissions) |
static void | SetReadOnly (const String &filePath, bool rdOnly=true) |
static void | SetReadWrite (const String &filePath) |
static String | SizeAsString (fsize_type sizeInBytes, int precision=3, bool alsoShowBytes=false) |
static String | SystemCacheDirectory () |
static String | SystemTempDirectory () |
static String | UniqueFileName (const String &directory=String(), int n=12, const String &prefix=String(), const String &postfix=String()) |
static String | UnixPathToWindows (const String &path) |
static String | WindowsPathToUnix (const String &path) |
template<typename E > | |
static void | Write (Flags< E > f) |
static void | WriteFile (const String &filePath, const ByteArray &contents) |
static void | WriteFile (const String &filePath, const ByteArray &contents, size_type start, size_type size) |
static void | WriteFile (const String &filePath, const void *data, size_type size) |
static void | WriteTextFile (const String &filePath, const IsoString &text) |
template<typename E > | |
static void | WriteUI32 (Flags< E > f) |
typedef void* pcl::File::handle |
typedef SeekMode::value_type pcl::File::seek_mode |
|
inline |
Constructs a File object that opens a file at a given path with the specified mode.
Definition at line 875 of file File.h.
References pcl::GenericString< T, R, A >::IsEmpty().
|
inlinevirtual |
|
delete |
Copy constructor. This constructor is disabled because files are unique objects.
Appends a postfix string to the current file name in the specified filePath. Returns the resulting path.
|
inlinevirtual |
|
inlinevirtual |
Changes the current file extension in filePath to a new extension ext. If it is not an empty string, the specified extension must include the initial dot separator.
If the specified new extension ext is an empty string, this function returns filePath with its extension (if any) removed.
Returns the resulting path after changing the file extension to the specified value.
|
virtual |
Closes an open file. If this file has not been opened, calling this member function has no effect.
|
static |
Copies a single file.
targetFilePath | Path to the target file, which must not exist. If the specified file exists, an Error exception will be thrown. |
sourceFilePath | Path to the source file. This file must exist and must be different from the specified target file. |
progress | Pointer to an instance of (a derived class of) File::Progress. If a non-null pointer is specified, the object will be used to provide progress information and the possibility of aborting the file copy operation. The default value is nullptr . |
The file copy operation is implemented as an iterative block copying routine. This means that huge files can be copied with minimal consumption of memory resources and no specific file size limit.
Along with the file contents, file access and modification times, as well as file access permissions, will also be copied by this function.
This function does not follow symbolic links. It does not copy the file pointed to by a symbolic link, but the link itself. This is only relevant to platforms that support symbolic links (i.e., all of them but Windows).
If a progress object is specified, it receives successive calls to File::Progress::Add() with increments in bytes. If the progress object aborts the file copy operation, this member function throws a ProcessAborted exception.
|
static |
Copies a symbolic link.
targetLinkPath | Path to the target file. A new symbolic link will be created at this path, which will point to the same link target as the source link. |
sourceLinkPath | Path to the source link, whose target will be copied to the target link. |
Note that this function creates a duplicate of the symbolic link itself, not of its pointed file.
|
static |
Copies access and modification times and access permissions from one file or directory item to another.
targetPath | Path to the target item whose times and permissions will be changed. |
sourcePath | Path to the source item whose times and permissions will be copied to the target item. |
|
inlinevirtual |
Creates a file at the specified path for exclusive read/write access. If a file already exists at the same path, its contents will be truncated to zero length.
Definition at line 1479 of file File.h.
Referenced by CreateFile().
|
static |
Creates a new directory at the specified dirPath.
If createIntermediateDirectories is true (the default value) and dirPath specifies one or more parent directories that don't exist, they are created automatically.
Returns a newly created file at the specified path, ready for exclusive write-only access. If a file already exists at the same path, its contents will be truncated to zero length.
Definition at line 1511 of file File.h.
References CreateForWriting().
|
inlinevirtual |
Creates a file at the specified path for exclusive write-only access. If a file already exists at the same path, its contents will be truncated to zero length.
Definition at line 1501 of file File.h.
Referenced by CreateFileForWriting().
|
static |
Returns true iff a directory at the specified dirPath exists.
|
static |
Returns true iff a file at the specified filePath exists.
Extracts the complete file suffix from the specified path.
Returns the extracted complete suffix, or an empty string if no file suffix was found. The returned string includes the initial dot separator.
The complete suffix is the ending substring of the file identifier in the specified path, starting with the first occurrence of a dot character. For example, in 'foo.tar.gz' the complete suffix is '.tar.gz'.
Referenced by pcl::FileInfo::CompleteSuffix().
Extracts a directory specification from the specified path.
Returns the extracted directory specification, or an empty string if no directory was found. On Windows, the drive element of the path is not included.
Examples:
In '/foo.tar.gz' the directory is '/'. In '/foo/bar.tar.gz' the directory is '/foo'. In 'foo/bar.tar.gz' the directory is 'foo'. In 'C:/Foo/Bar.txt' the directory is '/Foo'.
Referenced by pcl::FileInfo::Directory().
Extracts a Windows drive specification from the specified path.
Returns the extracted drive specification as a new string, or an empty string if no drive was found.
This function only makes sense on Windows. On UNIX and Linux operating systems, this function always returns an empty string.
Referenced by pcl::FileInfo::Drive().
Extracts a file extension from the specified path.
Returns the extracted extension, or an empty string if no file extension was found. The returned extension includes the initial dot separator.
Examples:
In '/foo/bar.tar.gz' the extension is '.gz'. In 'C:/Foo/Bar.txt' the extension is '.txt'.
Referenced by pcl::FileInfo::Extension().
Extracts a file name from the specified path.
Returns the extracted name, or an empty string if no file name was found. The file extension or suffix is not included.
Examples:
In '/foo/bar.tar.gz' the name is 'bar.tar'. In 'C:/Foo/Bar.txt' the name is 'Bar'.
Referenced by pcl::FileInfo::Name().
Extracts the file name and extension from the specified path. Calling this member function is functionally equivalent to:
File::ExtractName( path ) + File::ExtractExtension( path )
Referenced by pcl::FileInfo::NameAndExtension().
A synonym for ExtractNameAndExtension().
A synonym for ExtractExtension().
|
inline |
Returns the path of the file represented by this File object.
|
inline |
Returns a valid URI with the "file" scheme corresponding to the specified local path.
The returned URI is valid as specified by RFC 1738 and RFC 8089. The following characters will always be percent-encoded when present in the specified path:
The returned URI will include the specified path transformed to a full absolute local path with UNIX directory separators, encoded in UTF-8, percent-encoded as necessary, and prefixed with the "file://" scheme.
On Windows, a drive letter will always be present, prefixed with a root directory specifier, and the colon separator will be used; for example:
file:///c:/path/to/local%20file.txt
References:
https://tools.ietf.org/html/rfc1738
https://tools.ietf.org/html/rfc8089
Finds the complete file suffix in the specified path.
Returns the character index position of the complete suffix found, or String::notFound.
The complete suffix is the rightmost substring of the path starting with the first occurrence of a dot character. For example, in 'foo.tar.gz' the complete suffix is '.tar.gz'.
Finds a Windows drive specification in the specified path.
Returns the character index position of the drive found, or String::notFound.
This function only makes sense on Windows. On UNIX and Linux operating systems, this function always returns String::notFound.
Finds a file extension in the specified path.
Returns the character index position of the extension found, or String::notFound.
The file extension, or file suffix, is the rightmost substring of path starting with the last occurrence of a dot character. For example, in 'foo.tar.gz' the file extension is '.gz'.
Finds a file name in the specified path.
Returns the character index position of the name found, or String::notFound.
For example, in '/foo/bar.tar.gz' the file name is 'bar'.
A synonym for FindExtension().
void pcl::File::Flush | ( | ) |
Commits any pending write operations.
Returns the full, absolute local path to the specified path.
Referenced by pcl::DrizzleData::SetAlignmentTargetFilePath(), pcl::DrizzleData::SetCFASourceFilePath(), pcl::LocalNormalizationData::SetReferenceFilePath(), pcl::DrizzleData::SetSourceFilePath(), and pcl::LocalNormalizationData::SetTargetFilePath().
|
static |
Retrieves the storage space available on the device that supports a specified directory.
dirPath | A path specification to an existing directory on the local filesystem. On Windows, UNC paths are fully supported. Symbolic links are supported on all platforms. If a symbolic link is specified, the returned values refer to the target device. | |
[out] | totalBytes | If non-null, the address of a variable that receives the total capacity in bytes of the device that supports the specified directory. |
[out] | freeBytes | If non-null, the address of a variable that receives the total number of free bytes on the device that supports the specified directory. |
Returns the total number of bytes available on the device that supports the specified directory. The returned values take into account any disk quotas that might apply to the user associated with the calling process.
|
static |
Returns the home directory of the current user.
On FreeBSD, Linux and macOS, this function returns the value of the HOME environment variable if it is defined, nonempty, and is a valid path to an existing directory. In the extremely weird case this does not happen, the system root directory '/' is returned as a last resort.
On Windows, this function returns the root directory of the current user's profile. This is normally the value of the USERPROFILE environment variable. In case this fails, the HOMEDRIVE, HOMEPATH and HOME variables are checked for validity. If everything fails, the SYSTEMDRIVE variable is checked and ultimately "C:/" is returned.
|
inline |
|
inline |
|
static |
Returns true iff the file at filePath exists and the current user has read-only access to it.
|
inline |
Moves and/or renames a file.
filePath | Current path of the file to move/rename |
newFilePath | New path. If the directory in newFilePath is the same as in filePath, or if no directory is specified, the file is just renamed. If a different directory is specified, the file is also moved. |
|
static |
Moves a single file.
targetFilePath | Path to the target file, which must not exist. If the specified file exists, an Error exception will be thrown. |
sourceFilePath | Path to the source file. This file must exist and must be different from the specified target file. |
progress | Pointer to an instance of (a derived class of) File::Progress. If a non-null pointer is specified, the object will be used to provide progress information and the possibility of aborting the file copy operation. The default value is nullptr . |
For file move operations within the same physical device, this function implements a simple rename operation. In these cases, the progress object (if specified) receives a single call to File::Progress::Add() with the total file size in bytes.
When a file is moved to a different device, this member function first copies the source file to the target location using a routine equivalent to Copy(). When the entire file contents have been transferred, the source file is removed.
Along with the file contents, file access and modification times, as well as file access permissions, will be preserved by this function.
This function does not follow symbolic links. It does not move the file pointed to by a symbolic link, but the link itself. This is only relevant to platforms that support symbolic links (i.e., all of them but Windows).
If a progress object is specified and it aborts the file move operation, this member function throws a ProcessAborted exception. In such case the source file is guaranteed to remain intact.
|
virtual |
Opens or creates a file.
path | The path to the file to be opened or created. |
mode | Desired file access, share (Windows only) and opening/creation mode. By default, an existing file will be opened for (exclusive on Windows) read-only access. |
Returns an open existing file at the specified path. On Windows, the file is opened for shared read-only access (on UNIX and Linux, file access is handled automatically, so there is no need to define 'sharing modes').
Definition at line 1448 of file File.h.
References OpenForReading().
Returns an open existing file at the specified path, ready for exclusive read/write access.
Definition at line 1467 of file File.h.
References OpenForReadWrite().
|
inlinevirtual |
Opens an existing file at the specified path. On Windows, the file is opened for shared read-only access (on UNIX and Linux, file access is handled automatically, so there is no need to define 'sharing modes').
Definition at line 1437 of file File.h.
Referenced by OpenFileForReading().
|
inlinevirtual |
Opens an existing file at path for exclusive read/write access.
Definition at line 1458 of file File.h.
Referenced by OpenFileForReadWrite().
|
inline |
Opens a file at the specified path if it exists, or creates it otherwise. The file will be opened in exclusive read/write mode.
Definition at line 1522 of file File.h.
Referenced by OpenOrCreateFile().
Returns an open file at the specified path if it already exists, or a newly created file otherwise, ready for exclusive read/write access.
Definition at line 1531 of file File.h.
References OpenOrCreate().
Copy assignment. This operator is disabled because files are unique objects.
|
inline |
|
inline |
Writes a null-terminated 8-bit string as plain text.
Definition at line 1307 of file File.h.
References pcl::IsoCharTraits::Length().
|
inline |
Writes a dynamic 8-bit string as plain text.
Definition at line 1315 of file File.h.
References pcl::GenericString< T, R, A >::Begin(), and pcl::GenericString< T, R, A >::End().
|
inline |
|
inline |
Writes a null-terminated UTF-16 string as plain text.
Definition at line 1333 of file File.h.
References pcl::CharTraits::Length().
|
inline |
Writes a dynamic UTF16 string as plain text.
Definition at line 1341 of file File.h.
References pcl::GenericString< T, R, A >::Begin(), and pcl::GenericString< T, R, A >::End().
|
inline |
|
inline |
|
inline |
Writes an 8-bit newline character ('
').
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Returns the current file position, relative to the beginning of the file represented by this File object.
Prepends a prefix string to the current file name in the specified filePath. Returns the resulting path.
|
virtual |
Reads a contiguous block of len bytes into the specified buffer.
Referenced by pcl::StarDatabaseFile::Statistics().
|
inline |
|
inline |
void pcl::File::Read | ( | IsoString & | s | ) |
Reads a dynamic 8-bit string stored as binary data. The data should have been generated by a previous call to Write( const IsoString& ) on the file being read.
void pcl::File::Read | ( | String & | s | ) |
Reads a dynamic UTF-16 string stored as binary data. The data should have been generated by a previous call to Write( const IsoString& ) on the file being read.
|
inlinestatic |
|
inline |
Reads the contents of a file at the specified filePath and returns them as a ByteArray object.
|
inline |
|
inline |
|
static |
Reads all existing text lines from a file as 8-bit strings (e.g., ISO 8859-1 or UTF-8 formats) and returns them as a string list.
filePath | Path to the source file from which text lines will be read. |
options | Optional set of flags (ORed combination) that can be specified to control the way text lines are extracted and stored. Available flags are defined in the ReadTextOption namespace. |
Returns a string list (IsoStringList) with all existing lines in the specified file. If the file is empty, an empty string list is returned.
This routine automatically detects and processes line ending sequences characteristic of all supported platforms: UNIX (LF = 0x0A), Windows (CR+LF = 0x0D+0x0A) and legacy Mac (CR = 0x0D).
Reads the contents of a file at the specified filePath and returns them as plain text stored in a dynamic 8-bit string.
This function is useful to load document files encoded in UTF-8, ISO/IEC-8859-1 (or Latin-1), and other 8-bit encodings.
|
inline |
Reads a numeric variable as a 32-bit unsigned integer.
Definition at line 1088 of file File.h.
Referenced by pcl::GenericImage< UInt8PixelTraits >::Read().
|
inlinestatic |
|
inline |
|
static |
Removes an existing file at the specified filePath.
|
static |
Removes an existing empty directory at the specified dirPath.
The specified directory must be empty, or this function will fail.
|
virtual |
Truncates or extends this file to the specified length.
|
inline |
Returns true iff two files or directories are mounted on the same physical device.
This is relevant to some critical file operations. For example, moving a file on the same device is a simple and fast rename operation. However, moving a file across devices involves copying the entire file contents.
This function does not follow symbolic links. It does not consider mounted devices for files pointed to by symbolic links, but for the links themselves. This is only relevant to platforms that support symbolic links (all of them but Windows).
Returns true iff two file path specifications refer to the same file on the system.
On UNIX and Linux platforms, this function compares the device and inode numbers reported by the st_dev and st_ino members of the stat structure, respectively. This pair of numbers uniquely identifies every file on the system, irrespective of file names.
On Windows platforms, this function verifies the devices that support both files and, if they are the same, performs a case-insensitive comparison of the canonical absolute versions of the specified paths.
This function does not follow symbolic links. It does not consider mounted devices for files pointed to by symbolic links, but for the links themselves. This is only relevant to platforms that support symbolic links (all of them but Windows).
|
static |
Iterates a function through all existing text lines in a file.
filePath | Path to the source file from which text lines will be read. This file is assumed to store text as a sequence of 8-bit characters, e.g. ASCII, ISO 8859-1 or UTF-8. |
callback | Callback function. This function will be invoked once for each text line. The function will receive two arguments: a char* with the starting address of an 8-bit null terminated string, and a void* which is the specified data argument. The function will return true if the process can continue for the next text line; false to stop the iteration. |
data | A void* that will be passed to the callback function as its second argument on each call. The default value is nullptr . |
options | Optional set of flags (ORed combination) that can be specified to control the way text lines are explored and passed to the callback function. Available flags are defined in the ReadTextOption namespace. |
Returns the number of text lines that have been scanned, i.e. the number of times the callback function has been invoked and has returned true.
This routine avoids all the work associated with creating and storing new IsoString objects. When IsoString instances are not necessary to acquire the data being read, this routine can be much faster than ReadLines(), especially for vey large files.
This routine automatically detects and processes line ending sequences characteristic of all supported platforms: UNIX (LF = 0x0A), Windows (CR+LF = 0x0D+0x0A) and legacy Mac (CR = 0x0D).
Moves the file pointer. Returns the resulting pointer position from the file beginning.
dist | Distance to move in bytes. |
mode | Seek mode. See the SeekMode namespace for valid modes. |
|
inline |
|
static |
Changes the access permissions of a file or directory.
targetPath | Path to the existing file or directory whose permissions will be modified. |
permissions | An ORed combination of file permission flags. See the FilePermission namespace for contants. |
On UNIX and Linux platforms (FreeBSD, GNU Linux, Mac OS X), the read, write and execution permissions can be specified separately for the owner user, for the owner group, and for the rest of users. On Windows, only generic read and write permissions can be set, and there are no execution permissions.
|
virtual |
Sets the file position relative to the file beginning.
Referenced by pcl::StarDatabaseFile::Statistics().
|
static |
Enables or disables read-only access to a file at the specified filePath.
|
inlinestatic |
|
virtual |
Returns the length in bytes of this file.
|
static |
Returns a readable textual representation of a file size with automatic units conversion.
sizeInBytes | The file size in bytes. |
precision | The number of decimal digits used to represent floating point numbers. The default value is 3. |
alsoShowBytes | Whether to add the size in bytes to the string representation, irrespective of the units used. The default value is false. |
Examples:
|
static |
Returns the system cache storage directory.
On FreeBSD, Linux and Windows, this function is equivalent to SystemTempDirectory().
On macOS, this function returns the user's local cache folder, namely "~/Library/Caches" if it exists (it must), or SystemTempDirectory() otherwise.
|
static |
Returns the system temporary storage directory.
On FreeBSD, Linux and macOS, this function returns the value of the TMPDIR environment variable if it is defined, nonempty, and is a valid path to an existing directory. Otherwise this function returns "/tmp".
On Windows, this function returns the directory designated for storage of temporary files. Normally this is the value of the TMP or TEMP environment variable. If no valid directory can be retrieved this way (which is extremely weird), this function attempts to return the user's profile directory, as reported by the USERPROFILE variable. If that also fails, "C:/tmp" is returned if it exists, or the current working directory as a last resort.
|
static |
Returns a nonexistent, randomly generated file name.
directory | Name of an existing directory where the generated file name is guaranteed to be unique. If empty or not specified, the current directory of the calling process will be used. |
n | Number of random characters in the generated file name. Must be at least five characters. The default value is twelve characters. |
prefix | An optional prefix that will be prepended to the generated file name. |
postfix | An optional postfix that will be appended to the generated file name. |
This function returns the full absolute path of a nonexistent file name generated by concatenation of n random characters. For compatibility with case-insensitive file systems (FAT, NTFS), only uppercase characters and decimal digits are used in the generated file name.
The returned file name is guaranteed to be unique on the specified directory (or on the current directory of the calling process if no directory is specified) just after this function returns. Note that since a high-quality random number generator is used to select file name characters, there is no practical chance for a race condition by calling this function from several threads concurrently.
Converts a path from UNIX to Windows. Replaces all occurrences of the '/' UNIX separator with the '\' Windows separator.
Converts a path from Windows to UNIX syntax. Replaces all occurrences of the '\' Windows separator with the '/' UNIX separator.
|
virtual |
Writes a contiguous block of len bytes from the specified buffer.
|
inline |
|
inline |
void pcl::File::Write | ( | const char * | i, |
const char * | j | ||
) |
Writes a sequence of 8-bit characters, defined by the range [i,j), as binary data.
|
inline |
Writes a null-terminated 8-bit string as binary data.
Definition at line 1219 of file File.h.
References pcl::IsoCharTraits::Length().
|
inline |
Writes a dynamic 8-bit string as binary data.
Definition at line 1227 of file File.h.
References pcl::GenericString< T, R, A >::Begin(), and pcl::GenericString< T, R, A >::End().
void pcl::File::Write | ( | const char16_type * | i, |
const char16_type * | j | ||
) |
Writes a sequence of UTF-16 characters, defined by the range [i,j), as binary data.
|
inline |
Writes a null-terminated string of UTF-16 characters as binary data.
Definition at line 1241 of file File.h.
References pcl::CharTraits::Length().
|
inline |
Writes a dynamic UTF-16 string as binary data.
Definition at line 1249 of file File.h.
References pcl::GenericString< T, R, A >::Begin(), and pcl::GenericString< T, R, A >::End().
|
inlinestatic |
|
inline |
Creates a file with the specified contents.
filePath | Path to the file that will be created. |
contents | Reference to a ByteArray object providing the contents that will be written to the newly created file. |
Typically this function is used along with File::ReadFile() to implement a file copying routine; for example:
|
static |
Creates a file with a subset of a ByteArray container.
filePath | Path to the file that will be created. |
contents | Reference to a ByteArray object providing the contents that will be written to the newly created file. |
start | Zero-based index of the first byte to be written. |
size | Number of bytes that will be written. |
|
static |
Creates a file with the specified contents.
filePath | Path to the file that will be created. |
data | Pointer to the first byte to be written to the newly created file. |
size | Number of contiguous bytes, starting from data, to be written. |
|
inline |
|
inline |
Creates a file with the specified plain text content.
filePath | Path to the file that will be created. |
text | Reference to an IsoString object providing the plain text that will be written to the newly created file. |
This function is useful to generate document files encoded in UTF-8, ISO/IEC-8859-1 (or Latin-1), and other 8-bit encodings.
|
inline |
|
inlinestatic |
|
inline |