added Poco::File::linkTo()

This commit is contained in:
Günter Obiltschnig
2017-12-14 10:35:07 +01:00
parent 9472b163b4
commit d29972ef24
12 changed files with 129 additions and 26 deletions

View File

@@ -63,6 +63,13 @@ class Foundation_API File: private FileImpl
public:
typedef FileSizeImpl FileSize;
enum LinkType
/// Type of link for linkTo().
{
LINK_HARD = 0, /// hard link
LINK_SYMBOLIC = 1 /// symbolic link
};
File();
/// Creates the file.
@@ -189,6 +196,14 @@ public:
void renameTo(const std::string& path);
/// Renames the file to the new name.
void linkTo(const std::string& path, LinkType type = LINK_SYMBOLIC) const;
/// Creates a link (symbolic or hard, depending on type argument)
/// at the given path to the file or directory.
///
/// May not be supported on all platforms.
/// Furthermore, some operating systems do not allow creating
/// hard links to directories.
void remove(bool recursive = false);
/// Deletes the file. If recursive is true and the
/// file is a directory, recursively deletes all

View File

@@ -49,18 +49,19 @@ protected:
void setLastModifiedImpl(const Timestamp& ts);
FileSizeImpl getSizeImpl() const;
void setSizeImpl(FileSizeImpl size);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void copyToImpl(const std::string& path) const;
void renameToImpl(const std::string& path);
void linkToImpl(const std::string& path, int type) const;
void removeImpl();
bool createFileImpl();
bool createDirectoryImpl();
static void handleLastErrorImpl(const std::string& path);
private:
std::string _path;
friend class DirectoryIteratorImpl;
friend class LinuxDirectoryWatcherStrategy;
friend class BSDDirectoryWatcherStrategy;

View File

@@ -49,18 +49,19 @@ protected:
void setLastModifiedImpl(const Timestamp& ts);
FileSizeImpl getSizeImpl() const;
void setSizeImpl(FileSizeImpl size);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void copyToImpl(const std::string& path) const;
void renameToImpl(const std::string& path);
void linkToImpl(const std::string& path, int type) const;
void removeImpl();
bool createFileImpl();
bool createDirectoryImpl();
static void handleLastErrorImpl(const std::string& path);
private:
std::string _path;
friend class DirectoryIteratorImpl;
};

View File

@@ -50,18 +50,19 @@ protected:
void setLastModifiedImpl(const Timestamp& ts);
FileSizeImpl getSizeImpl() const;
void setSizeImpl(FileSizeImpl size);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void copyToImpl(const std::string& path) const;
void renameToImpl(const std::string& path);
void linkToImpl(const std::string& path, int type) const;
void removeImpl();
bool createFileImpl();
bool createDirectoryImpl();
static void handleLastErrorImpl(const std::string& path);
private:
std::string _path;
friend class FileHandle;
friend class DirectoryIteratorImpl;
friend class WindowsDirectoryWatcherStrategy;

View File

@@ -50,20 +50,21 @@ protected:
void setLastModifiedImpl(const Timestamp& ts);
FileSizeImpl getSizeImpl() const;
void setSizeImpl(FileSizeImpl size);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void copyToImpl(const std::string& path) const;
void renameToImpl(const std::string& path);
void linkToImpl(const std::string& path, int type) const;
void removeImpl();
bool createFileImpl();
bool createDirectoryImpl();
static void handleLastErrorImpl(const std::string& path);
static void convertPath(const std::string& utf8Path, std::wstring& utf16Path);
private:
std::string _path;
std::wstring _upath;
friend class FileHandle;
friend class DirectoryIteratorImpl;
friend class WindowsDirectoryWatcherStrategy;

View File

@@ -50,20 +50,21 @@ protected:
void setLastModifiedImpl(const Timestamp& ts);
FileSizeImpl getSizeImpl() const;
void setSizeImpl(FileSizeImpl size);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void setWriteableImpl(bool flag = true);
void setExecutableImpl(bool flag = true);
void copyToImpl(const std::string& path) const;
void renameToImpl(const std::string& path);
void linkToImpl(const std::string& path, int type) const;
void removeImpl();
bool createFileImpl();
bool createDirectoryImpl();
static void handleLastErrorImpl(const std::string& path);
static void convertPath(const std::string& utf8Path, std::wstring& utf16Path);
private:
std::string _path;
std::wstring _upath;
friend class FileHandle;
friend class DirectoryIteratorImpl;
friend class FileStreamBuf;