mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-12 22:22:55 +00:00
FileManager: Allow creating desktop shortcut from FileManager
This commit is contained in:
parent
ca2e7b6746
commit
abc98dea09
Notes:
sideshowbarker
2024-07-19 00:40:05 +09:00
Author: https://github.com/lxea
Commit: abc98dea09
Pull-request: https://github.com/SerenityOS/serenity/pull/4497
3 changed files with 46 additions and 0 deletions
|
@ -235,6 +235,23 @@ bool copy_file(const String& dst_path, const struct stat& src_stat, Core::File&
|
|||
return true;
|
||||
}
|
||||
|
||||
bool link_file(const String& src_path, const String& dst_path)
|
||||
{
|
||||
int duplicate_count = 0;
|
||||
while (access(get_duplicate_name(dst_path, duplicate_count).characters(), F_OK) == 0) {
|
||||
++duplicate_count;
|
||||
}
|
||||
if (duplicate_count != 0) {
|
||||
return link_file(src_path, get_duplicate_name(dst_path, duplicate_count));
|
||||
}
|
||||
int rc = symlink(src_path.characters(), dst_path.characters());
|
||||
if (rc < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
String get_duplicate_name(const String& path, int duplicate_count)
|
||||
{
|
||||
if (duplicate_count == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue