< prev index next >

src/jdk.jpackage/windows/native/libjpackage/FileUtils.h

Print this page

        

*** 41,57 **** // checks is the specified file is a directory // returns false if the path does not exist bool isDirectory(const tstring &filePath); ! //checks if the specified directory is not empty ! //returns true if the path is an existing directory and it contains at least one file other than "." or "..". bool isDirectoryNotEmpty(const tstring &dirPath); // returns directory part of the path. // returns empty string if the path contains only filename. ! // if the path ends with slash/backslash, returns removeTrailingSlashes(path). tstring dirname(const tstring &path); // returns basename part of the path // if the path ends with slash/backslash, returns empty string. tstring basename(const tstring &path); --- 41,59 ---- // checks is the specified file is a directory // returns false if the path does not exist bool isDirectory(const tstring &filePath); ! // checks if the specified directory is not empty ! // returns true if the path is an existing directory and ! // it contains at least one file other than "." or "..". bool isDirectoryNotEmpty(const tstring &dirPath); // returns directory part of the path. // returns empty string if the path contains only filename. ! // if the path ends with slash/backslash, ! // returns removeTrailingSlashes(path). tstring dirname(const tstring &path); // returns basename part of the path // if the path ends with slash/backslash, returns empty string. tstring basename(const tstring &path);
*** 71,92 **** tstring combinePath(const tstring& parent, const tstring& child); // removes trailing slashes and backslashes in the path if any tstring removeTrailingSlash(const tstring& path); ! // Creates a file with unique name in the specified base directory, throws an exception if operation fails // path is constructed as <prefix><random number><suffix>. // The function fails and throws exception if 'path' doesn't exist. ! tstring createTempFile(const tstring &prefix = _T(""), const tstring &suffix = _T(".tmp"), const tstring &path=SysInfo::getTempDir()); ! // Creates a directory with unique name in the specified base directory, throws an exception if operation fails // path is constructed as <prefix><random number><suffix> // The function fails and throws exception if 'path' doesn't exist. ! tstring createTempDirectory(const tstring &prefix = _T(""), const tstring &suffix = _T(".tmp"), const tstring &basedir=SysInfo::getTempDir()); ! // If the file referenced with "prototype" parameter DOES NOT exist, the return ! // value is the given path. No new files created. // Otherwise the function creates another file in the same directory as // the given file with the same suffix and with the basename from the // basename of the given file with some random chars appended to ensure // created file is unique. tstring createUniqueFile(const tstring &prototype); --- 73,100 ---- tstring combinePath(const tstring& parent, const tstring& child); // removes trailing slashes and backslashes in the path if any tstring removeTrailingSlash(const tstring& path); ! // Creates a file with unique name in the specified base directory, ! // throws an exception if operation fails // path is constructed as <prefix><random number><suffix>. // The function fails and throws exception if 'path' doesn't exist. ! tstring createTempFile(const tstring &prefix = _T(""), ! const tstring &suffix = _T(".tmp"), ! const tstring &path=SysInfo::getTempDir()); ! // Creates a directory with unique name in the specified base directory, ! // throws an exception if operation fails // path is constructed as <prefix><random number><suffix> // The function fails and throws exception if 'path' doesn't exist. ! tstring createTempDirectory(const tstring &prefix = _T(""), ! const tstring &suffix = _T(".tmp"), ! const tstring &basedir=SysInfo::getTempDir()); ! // If the file referenced with "prototype" parameter DOES NOT exist, ! // the return value is the given path. No new files created. // Otherwise the function creates another file in the same directory as // the given file with the same suffix and with the basename from the // basename of the given file with some random chars appended to ensure // created file is unique. tstring createUniqueFile(const tstring &prototype);
*** 95,109 **** // Currently supports only "standard" path like "c:\bla-bla" // If 'createdDirs' parameter is not NULL, the given array is appended with // all subdirectories created by this function call. void createDirectory(const tstring &path, tstring_array* createdDirs=0); ! // copies file from fromPath to toPath. Creates output directory if doesn't exist. ! void copyFile(const tstring& fromPath, const tstring& toPath, bool failIfExists); ! ! // moves file from fromPath to toPath. Creates output directory if doesn't exist. ! void moveFile(const tstring& fromPath, const tstring& toPath, bool failIfExists); // Throws exception if fails to delete specified 'path'. // Exits normally if 'path' doesn't exist or it has been deleted. // Attempts to strip R/O attribute if delete fails and retry delete. void deleteFile(const tstring &path); --- 103,121 ---- // Currently supports only "standard" path like "c:\bla-bla" // If 'createdDirs' parameter is not NULL, the given array is appended with // all subdirectories created by this function call. void createDirectory(const tstring &path, tstring_array* createdDirs=0); ! // copies file from fromPath to toPath. ! // Creates output directory if doesn't exist. ! void copyFile(const tstring& fromPath, const tstring& toPath, ! bool failIfExists); ! ! // moves file from fromPath to toPath. ! // Creates output directory if doesn't exist. ! void moveFile(const tstring& fromPath, const tstring& toPath, ! bool failIfExists); // Throws exception if fails to delete specified 'path'. // Exits normally if 'path' doesn't exist or it has been deleted. // Attempts to strip R/O attribute if delete fails and retry delete. void deleteFile(const tstring &path);
*** 129,142 **** // Returns 'false' if 'dirPath' references existing file system object // which is not a directory or if failed to delete one ore more files in // 'dirPath' directory. // Doesn't abort iteration over files if the given directory after the // first failure to delete a file. ! bool deleteFilesInDirectory(const tstring &dirPath, const std::nothrow_t &) throw(); // Like deleteFilesInDirectory, but deletes subdirectories as well void deleteDirectoryRecursive(const tstring &dirPath); ! bool deleteDirectoryRecursive(const tstring &dirPath, const std::nothrow_t &) throw(); class DirectoryCallback { public: virtual ~DirectoryCallback() {}; --- 141,156 ---- // Returns 'false' if 'dirPath' references existing file system object // which is not a directory or if failed to delete one ore more files in // 'dirPath' directory. // Doesn't abort iteration over files if the given directory after the // first failure to delete a file. ! bool deleteFilesInDirectory(const tstring &dirPath, ! const std::nothrow_t &) throw(); // Like deleteFilesInDirectory, but deletes subdirectories as well void deleteDirectoryRecursive(const tstring &dirPath); ! bool deleteDirectoryRecursive(const tstring &dirPath, ! const std::nothrow_t &) throw(); class DirectoryCallback { public: virtual ~DirectoryCallback() {};
*** 199,211 **** bool theWithFolders; tstring root; tstring_array items; }; ! // Returns array of all the files/sub-folders from the given directory, empty array if basedir is not a directory. The returned ! // array is ordered from top down (i.e. dirs are listed first followed by subfolders and files). ! // Order of subfolders and files is undefined but usually they are sorted by names. inline tstring_array listAllContents(const tstring& basedir) { return DirectoryIterator(basedir).findItems(); } // Helper to construct path from multiple components. --- 213,228 ---- bool theWithFolders; tstring root; tstring_array items; }; ! // Returns array of all the files/sub-folders from the given directory, ! // empty array if basedir is not a directory. The returned ! // array is ordered from top down (i.e. dirs are listed first followed ! // by subfolders and files). ! // Order of subfolders and files is undefined ! // but usually they are sorted by names. inline tstring_array listAllContents(const tstring& basedir) { return DirectoryIterator(basedir).findItems(); } // Helper to construct path from multiple components.
*** 238,248 **** struct Directory { Directory() { } ! Directory(const tstring &parent, const tstring &subdir) : parent(parent), subdir(subdir) { } operator tstring () const { return getPath(); } --- 255,266 ---- struct Directory { Directory() { } ! Directory(const tstring &parent, ! const tstring &subdir) : parent(parent), subdir(subdir) { } operator tstring () const { return getPath(); }
*** 311,325 **** appendFile(FileUtils::mkpath() << dirname << *it); } return *this; } ! // Schedule empty directory for deletion with empty roots (up to Directory.parent). Deleter& appendEmptyDirectory(const Directory& dir); // Schedule empty directory for deletion without roots. ! // This is a particular case of appendEmptyDirectory(const Directory& dir) // with Directory(dirname(path), basename(path)). Deleter& appendEmptyDirectory(const tstring& path); // Schedule all file from the given directory for deletion. Deleter& appendAllFilesInDirectory(const tstring& path); --- 329,345 ---- appendFile(FileUtils::mkpath() << dirname << *it); } return *this; } ! // Schedule empty directory for deletion with empty roots ! // (up to Directory.parent). Deleter& appendEmptyDirectory(const Directory& dir); // Schedule empty directory for deletion without roots. ! // This is a particular case of ! // appendEmptyDirectory(const Directory& dir) // with Directory(dirname(path), basename(path)). Deleter& appendEmptyDirectory(const tstring& path); // Schedule all file from the given directory for deletion. Deleter& appendAllFilesInDirectory(const tstring& path);
< prev index next >