Fix wrong sprintf usage: the parameters use the restrict keyword so they may not point to the same location.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5286 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
33a005c801
commit
c26a34d4a5
|
@ -492,32 +492,37 @@ bool DeleteDirRecursively(const char *directory)
|
|||
//Create directory and copy contents (does not overwrite existing files)
|
||||
void CopyDir(const char *source_path, const char *dest_path)
|
||||
{
|
||||
if (!File::Exists(source_path))
|
||||
return;
|
||||
|
||||
if (!strcmp(source_path, dest_path)) return;
|
||||
if (!File::Exists(source_path)) return;
|
||||
if (!File::Exists(dest_path)) File::CreateFullPath(dest_path);
|
||||
|
||||
char *virtualName;
|
||||
struct dirent dirent, *result = NULL;
|
||||
DIR *dirp = opendir(source_path);
|
||||
if (!dirp)
|
||||
return;
|
||||
while (!readdir_r(dirp, &dirent, &result) && result) {
|
||||
if (!dirp) return;
|
||||
|
||||
while (!readdir_r(dirp, &dirent, &result) && result)
|
||||
{
|
||||
virtualName = result->d_name;
|
||||
// check for "." and ".."
|
||||
if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
|
||||
((virtualName[0] == '.') && (virtualName[1] == '.') &&
|
||||
(virtualName[2] == '\0')))
|
||||
continue;
|
||||
char source[300], dest[300];
|
||||
|
||||
char source[FILENAME_MAX], dest[FILENAME_MAX];
|
||||
sprintf(source, "%s%s", source_path, virtualName);
|
||||
sprintf(dest, "%s%s", dest_path, virtualName);
|
||||
if (IsDirectory(source)) {
|
||||
sprintf(source, "%s/", source);
|
||||
sprintf(dest, "%s/", dest);
|
||||
if (IsDirectory(source))
|
||||
{
|
||||
const unsigned int srclen = strlen(source);
|
||||
const unsigned int destlen = strlen(dest);
|
||||
source[srclen] = '/'; source[srclen+1] = '\0';
|
||||
dest[destlen] = '/'; dest[destlen+1] = '\0';
|
||||
if (!File::Exists(dest)) File::CreateFullPath(dest);
|
||||
CopyDir(source, dest);
|
||||
} else
|
||||
if (!File::Exists(dest)) File::Copy(source, dest);
|
||||
}
|
||||
else if (!File::Exists(dest)) File::Copy(source, dest);
|
||||
}
|
||||
closedir(dirp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue