Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6caf53d1
Commit
6caf53d1
authored
8 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/FileSystem: RenameFile() throws exception on error
parent
dee6e498
sisyphus
0.23.15-alt1
0.23.14-alt1
0.23.13-alt1
0.23.12-alt1
0.23.11-alt1
0.23.8-alt3
0.23.8-alt2
0.23.8-alt1
0.21.24-alt1.1
0.21.24-alt1
0.20.23-alt3
0.20.23-alt2
0.20.23-alt1
0.20.21-alt1
0.20.15-alt1
mpd/0.20.6-alt1
gb-sisyphus-task339776.6100
gb-sisyphus-task337393.100
gb-sisyphus-task337176.300
gb-sisyphus-task334590.100
gb-sisyphus-task333607.100
gb-sisyphus-task331543.2500
gb-sisyphus-task328663.4700
gb-sisyphus-task325064.100
gb-sisyphus-task319111.4000
gb-sisyphus-task313704.100
gb-sisyphus-task312885.100
gb-sisyphus-task308905.3200
gb-sisyphus-task305294.500
gb-sisyphus-task304007.100
gb-sisyphus-task303674.1700
gb-sisyphus-task298681.300
gb-sisyphus-task296051.1000
gb-sisyphus-task274827.100
gb-sisyphus-task269249.2000
gb-sisyphus-task266579.400
gb-sisyphus-task258132.600
gb-sisyphus-task254601.200
gb-sisyphus-task253310.100
gb-sisyphus-task252214.300
gb-sisyphus-task251539.6100
gb-sisyphus-task247988.7000
gb-sisyphus-task238768.6000
gb-sisyphus-task229151.100
gb-sisyphus-task227574.200
gb-sisyphus-task226762.6000
gb-sisyphus-task219546.1700
gb-sisyphus-task213491.100
gb-sisyphus-task198806.100
gb-sisyphus-task181400.100
gb-p9-task277538.2600
gb-c9f2-task327704.1100
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
30 deletions
+27
-30
PlaylistFile.cxx
src/PlaylistFile.cxx
+9
-20
FileSystem.cxx
src/fs/FileSystem.cxx
+13
-0
FileSystem.hxx
src/fs/FileSystem.hxx
+5
-10
No files found.
src/PlaylistFile.cxx
View file @
6caf53d1
...
@@ -122,24 +122,6 @@ spl_map_to_fs(const char *name_utf8)
...
@@ -122,24 +122,6 @@ spl_map_to_fs(const char *name_utf8)
return
path_fs
;
return
path_fs
;
}
}
/**
* Throw an exception for the current errno.
*/
static
void
ThrowPlaylistErrno
()
{
switch
(
errno
)
{
case
ENOENT
:
throw
PlaylistError
(
PlaylistResult
::
NO_SUCH_LIST
,
"No such playlist"
);
default
:
throw
std
::
system_error
(
std
::
error_code
(
errno
,
std
::
system_category
()),
"Error"
);
}
}
static
bool
static
bool
LoadPlaylistFileInfo
(
PlaylistInfo
&
info
,
LoadPlaylistFileInfo
(
PlaylistInfo
&
info
,
const
Path
parent_path_fs
,
const
Path
parent_path_fs
,
...
@@ -392,8 +374,15 @@ spl_rename_internal(Path from_path_fs, Path to_path_fs)
...
@@ -392,8 +374,15 @@ spl_rename_internal(Path from_path_fs, Path to_path_fs)
throw
PlaylistError
(
PlaylistResult
::
LIST_EXISTS
,
throw
PlaylistError
(
PlaylistResult
::
LIST_EXISTS
,
"Playlist exists already"
);
"Playlist exists already"
);
if
(
!
RenameFile
(
from_path_fs
,
to_path_fs
))
try
{
ThrowPlaylistErrno
();
RenameFile
(
from_path_fs
,
to_path_fs
);
}
catch
(
const
std
::
system_error
&
e
)
{
if
(
IsPathNotFound
(
e
))
throw
PlaylistError
(
PlaylistResult
::
NO_SUCH_LIST
,
"No such playlist"
);
else
throw
;
}
idle_add
(
IDLE_STORED_PLAYLIST
);
idle_add
(
IDLE_STORED_PLAYLIST
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/fs/FileSystem.cxx
View file @
6caf53d1
...
@@ -26,6 +26,19 @@
...
@@ -26,6 +26,19 @@
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
void
RenameFile
(
Path
oldpath
,
Path
newpath
)
{
#ifdef WIN32
if
(
!
MoveFileEx
(
oldpath
.
c_str
(),
newpath
.
c_str
(),
MOVEFILE_REPLACE_EXISTING
))
throw
MakeLastError
(
"Failed to rename file"
);
#else
if
(
rename
(
oldpath
.
c_str
(),
newpath
.
c_str
())
<
0
)
throw
MakeErrno
(
"Failed to rename file"
);
#endif
}
AllocatedPath
AllocatedPath
ReadLink
(
Path
path
)
ReadLink
(
Path
path
)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/fs/FileSystem.hxx
View file @
6caf53d1
...
@@ -63,18 +63,13 @@ OpenFile(Path file, int flags, int mode)
...
@@ -63,18 +63,13 @@ OpenFile(Path file, int flags, int mode)
#endif
#endif
}
}
/*
*
/*
* Wrapper for rename() that uses #Path names.
* Wrapper for rename() that uses #Path names.
*
* Throws std::system_error on error.
*/
*/
static
inline
bool
void
RenameFile
(
Path
oldpath
,
Path
newpath
)
RenameFile
(
Path
oldpath
,
Path
newpath
);
{
#ifdef WIN32
return
_trename
(
oldpath
.
c_str
(),
newpath
.
c_str
())
==
0
;
#else
return
rename
(
oldpath
.
c_str
(),
newpath
.
c_str
())
==
0
;
#endif
}
#ifndef WIN32
#ifndef WIN32
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment