13
0

Add PBD API to hard-link files

This commit is contained in:
Robin Gareus 2019-08-12 16:41:25 +02:00
parent c0f0acaa9f
commit ffbf40c3d1
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 16 additions and 0 deletions

View File

@ -356,6 +356,17 @@ touch_file (const std::string& path)
return false;
}
bool
hard_link (const std::string& existing_file, const std::string& new_path)
{
#ifdef PLATFORM_WINDOWS
/* see also ntfs_link -- msvc only pbd extension */
return CreateHardLinkA (new_path.c_str(), existing_file.c_str(), NULL);
#else
return 0 == link (existing_file.c_str(), new_path.c_str());
#endif
}
std::string
get_absolute_path (const std::string & p)
{

View File

@ -190,6 +190,11 @@ LIBPBD_API void copy_recurse(const std::string & from_path, const std::string &
*/
LIBPBD_API bool touch_file (const std::string& path);
/** try hard-link a file
* @return true if file was successfully linked
*/
LIBPBD_API bool hard_link (const std::string& existing_file, const std::string& new_path);
/**
* Take a (possibly) relative path and make it absolute
* @return An absolute path