mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 11:46:25 +01:00
Use ::g_rename instead of ::rename in ARDOUR::FileSource class
The path is in UTF-8 encoding so use Glib functions to properly support paths containing characters that aren't in the system codepage. This fixes Clean-up Unused Sources on Windows where paths contain characters that aren't in the system codepage(usually most non-ascii characters).
This commit is contained in:
parent
e297e27b7f
commit
331bfef416
1 changed files with 6 additions and 4 deletions
|
|
@ -21,11 +21,13 @@
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdio.h> // for rename(), sigh
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include "pbd/convert.h"
|
#include "pbd/convert.h"
|
||||||
#include "pbd/basename.h"
|
#include "pbd/basename.h"
|
||||||
#include "pbd/stl_delete.h"
|
#include "pbd/stl_delete.h"
|
||||||
|
|
@ -205,7 +207,7 @@ FileSource::move_to_trash (const string& trash_dir_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::rename (_path.c_str(), newpath.c_str()) != 0) {
|
if (::g_rename (_path.c_str(), newpath.c_str()) != 0) {
|
||||||
PBD::error << string_compose (
|
PBD::error << string_compose (
|
||||||
_("cannot rename file source from %1 to %2 (%3)"),
|
_("cannot rename file source from %1 to %2 (%3)"),
|
||||||
_path, newpath, strerror (errno)) << endmsg;
|
_path, newpath, strerror (errno)) << endmsg;
|
||||||
|
|
@ -214,7 +216,7 @@ FileSource::move_to_trash (const string& trash_dir_name)
|
||||||
|
|
||||||
if (move_dependents_to_trash() != 0) {
|
if (move_dependents_to_trash() != 0) {
|
||||||
/* try to back out */
|
/* try to back out */
|
||||||
::rename (newpath.c_str(), _path.c_str());
|
::g_rename (newpath.c_str(), _path.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -592,7 +594,7 @@ FileSource::rename (const string& newpath)
|
||||||
|
|
||||||
if (Glib::file_test (oldpath.c_str(), Glib::FILE_TEST_EXISTS)) {
|
if (Glib::file_test (oldpath.c_str(), Glib::FILE_TEST_EXISTS)) {
|
||||||
/* rename only needed if file exists on disk */
|
/* rename only needed if file exists on disk */
|
||||||
if (::rename (oldpath.c_str(), newpath.c_str()) != 0) {
|
if (::g_rename (oldpath.c_str(), newpath.c_str()) != 0) {
|
||||||
error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, strerror(errno)) << endmsg;
|
error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, strerror(errno)) << endmsg;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue