Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
941a722f
There was an error fetching the commit references. Please try again later.
Commit
941a722f
authored
7 years ago
by
James
Browse files
Options
Downloads
Patches
Plain Diff
Handle invalid filenames when renaming files/directories
parent
60024ad7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/file_sys/archive_sdmc.cpp
+39
-2
39 additions, 2 deletions
src/core/file_sys/archive_sdmc.cpp
src/core/file_sys/savedata_archive.cpp
+39
-2
39 additions, 2 deletions
src/core/file_sys/savedata_archive.cpp
with
78 additions
and
4 deletions
src/core/file_sys/archive_sdmc.cpp
+
39
−
2
View file @
941a722f
...
...
@@ -121,7 +121,25 @@ ResultCode SDMCArchive::DeleteFile(const Path& path) const {
}
ResultCode
SDMCArchive
::
RenameFile
(
const
Path
&
src_path
,
const
Path
&
dest_path
)
const
{
if
(
FileUtil
::
Rename
(
mount_point
+
src_path
.
AsString
(),
mount_point
+
dest_path
.
AsString
()))
{
const
PathParser
path_parser_src
(
src_path
);
// TODO: Verify these return codes with HW
if
(
!
path_parser_src
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid src path %s"
,
src_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
PathParser
path_parser_dest
(
dest_path
);
if
(
!
path_parser_dest
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid dest path %s"
,
dest_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
auto
src_path_full
=
path_parser_src
.
BuildHostPath
(
mount_point
);
const
auto
dest_path_full
=
path_parser_dest
.
BuildHostPath
(
mount_point
);
if
(
FileUtil
::
Rename
(
src_path_full
,
dest_path_full
))
{
return
RESULT_SUCCESS
;
}
...
...
@@ -260,8 +278,27 @@ ResultCode SDMCArchive::CreateDirectory(const Path& path) const {
}
ResultCode
SDMCArchive
::
RenameDirectory
(
const
Path
&
src_path
,
const
Path
&
dest_path
)
const
{
if
(
FileUtil
::
Rename
(
mount_point
+
src_path
.
AsString
(),
mount_point
+
dest_path
.
AsString
()))
const
PathParser
path_parser_src
(
src_path
);
// TODO: Verify these return codes with HW
if
(
!
path_parser_src
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid src path %s"
,
src_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
PathParser
path_parser_dest
(
dest_path
);
if
(
!
path_parser_dest
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid dest path %s"
,
dest_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
auto
src_path_full
=
path_parser_src
.
BuildHostPath
(
mount_point
);
const
auto
dest_path_full
=
path_parser_dest
.
BuildHostPath
(
mount_point
);
if
(
FileUtil
::
Rename
(
src_path_full
,
dest_path_full
))
{
return
RESULT_SUCCESS
;
}
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify.
...
...
This diff is collapsed.
Click to expand it.
src/core/file_sys/savedata_archive.cpp
+
39
−
2
View file @
941a722f
...
...
@@ -106,7 +106,25 @@ ResultCode SaveDataArchive::DeleteFile(const Path& path) const {
}
ResultCode
SaveDataArchive
::
RenameFile
(
const
Path
&
src_path
,
const
Path
&
dest_path
)
const
{
if
(
FileUtil
::
Rename
(
mount_point
+
src_path
.
AsString
(),
mount_point
+
dest_path
.
AsString
()))
{
const
PathParser
path_parser_src
(
src_path
);
// TODO: Verify these return codes with HW
if
(
!
path_parser_src
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid src path %s"
,
src_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
PathParser
path_parser_dest
(
dest_path
);
if
(
!
path_parser_dest
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid dest path %s"
,
dest_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
auto
src_path_full
=
path_parser_src
.
BuildHostPath
(
mount_point
);
const
auto
dest_path_full
=
path_parser_dest
.
BuildHostPath
(
mount_point
);
if
(
FileUtil
::
Rename
(
src_path_full
,
dest_path_full
))
{
return
RESULT_SUCCESS
;
}
...
...
@@ -247,8 +265,27 @@ ResultCode SaveDataArchive::CreateDirectory(const Path& path) const {
}
ResultCode
SaveDataArchive
::
RenameDirectory
(
const
Path
&
src_path
,
const
Path
&
dest_path
)
const
{
if
(
FileUtil
::
Rename
(
mount_point
+
src_path
.
AsString
(),
mount_point
+
dest_path
.
AsString
()))
const
PathParser
path_parser_src
(
src_path
);
// TODO: Verify these return codes with HW
if
(
!
path_parser_src
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid src path %s"
,
src_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
PathParser
path_parser_dest
(
dest_path
);
if
(
!
path_parser_dest
.
IsValid
())
{
LOG_ERROR
(
Service_FS
,
"Invalid dest path %s"
,
dest_path
.
DebugStr
().
c_str
());
return
ERROR_INVALID_PATH
;
}
const
auto
src_path_full
=
path_parser_src
.
BuildHostPath
(
mount_point
);
const
auto
dest_path_full
=
path_parser_dest
.
BuildHostPath
(
mount_point
);
if
(
FileUtil
::
Rename
(
src_path_full
,
dest_path_full
))
{
return
RESULT_SUCCESS
;
}
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment