Fixes root directory creation in Windows.

This commit is contained in:
Andrea Mazzoleni 2013-07-10 18:33:19 +02:00
parent e8b2d359d6
commit 3768ac329c
3 changed files with 22 additions and 2 deletions

View file

@ -22,6 +22,15 @@ SnapRAID HISTORY
directory tree.
* Changes the 'dup' output format to include the size of each duplicate file.
3.2 2013/7
==========
* Fix a directory creation problem in Windows when the "disk" option points to
the root directory of a drive. Now SnapRAID won't complain about the
inability to create such directory.
If you encouter this problem when trying to recover your data, just upgrade
to this version, and you'll be able to complete the recovering process.
No need to upgrade for platforms different from Windows.
3.1 2013/5
==========
* Direct use of Windows API for disk access to improve error reporting.

2
TODO
View file

@ -5,6 +5,8 @@ This is the list of TODO items for SnapRAID.
- v4.0
* Don't enforce different disk in fix. It could allow to recover in spare space of a disk already used.
* In the import list, uses also all the blocks in the array.
But we must cover the case of bad blocks. Likely we can just check the
hash after reading, and in case, skip it, and retry with another copy.

13
util.c
View file

@ -687,9 +687,9 @@ int mkancestor(const char* file)
{
char dir[PATH_MAX];
char* c;
pathcpy(dir, sizeof(dir), file);
c = strrchr(dir, '/');
if (!c) {
/* no ancestor */
@ -699,11 +699,20 @@ int mkancestor(const char* file)
/* clear the file */
*c = 0;
/* if it's the root dir */
if (*dir == 0) {
/* nothing more to do */
return 0;
}
#ifdef _WIN32
/* if it's a drive specificaion like "C:" */
if (isalpha(dir[0]) && dir[1] == ':' && dir[2] == 0) {
/* nothing more to do */
return 0;
}
#endif
/* try creating it */
if (mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0) {
/* just created */