Skip to content

Commit 8f1fc30

Browse files
authored
Merge pull request #279 from jolavillette/FixWindowsDriveRootSharing
fix: handle Windows drive root paths (C:/) in shared directories to prevent 0 files shown
2 parents ca004ea + a2a697e commit 8f1fc30

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/file_sharing/directory_updater.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(
303303
if(dir_is_accepted && mFollowSymLinks && mIgnoreDuplicates)
304304
{
305305
std::string real_path = RsDirUtil::removeSymLinks(
306-
cumulated_path + "/" + dirIt.file_name() );
306+
RsDirUtil::makePath(cumulated_path, dirIt.file_name()) );
307307

308308
if( existing_directories.end() !=
309309
existing_directories.find(real_path) )
@@ -355,7 +355,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(
355355
* The later is always needed. */
356356

357357
if( mHashCache->requestHash(
358-
cumulated_path + "/" + dit.name(),
358+
RsDirUtil::makePath(cumulated_path, dit.name()),
359359
dit.size(), dit.modtime(), hash, this, *dit ) )
360360
mSharedDirectories->updateHash(*dit, hash, hash != dit.hash());
361361
}
@@ -364,7 +364,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(
364364
// go through the list of sub-dirs and recursively update
365365
for( DirectoryStorage::DirIterator stored_dir_it(mSharedDirectories, indx);
366366
stored_dir_it; ++stored_dir_it )
367-
recursUpdateSharedDir( cumulated_path + "/" + stored_dir_it.name(),
367+
recursUpdateSharedDir( RsDirUtil::makePath(cumulated_path, stored_dir_it.name()),
368368
*stored_dir_it, existing_directories,
369369
current_depth+1, some_files_not_ready );
370370
}

src/util/folderiterator.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "util/rswin.h"
3535
#endif
3636

37+
#include "util/rsdir.h"
38+
3739

3840
//#define DEBUG_FOLDER_ITERATOR 1
3941

@@ -137,7 +139,7 @@ bool FolderIterator::updateFileInfo(bool& should_skip)
137139
return true ;
138140
}
139141

140-
mFullPath = mFolderName + "/" + mFileName ;
142+
mFullPath = RsDirUtil::makePath(mFolderName, mFileName);
141143

142144
#warning cyril soler: should we take care of symbolic links on windows?
143145
#ifndef WINDOWS_SYS

src/util/rsdir.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,10 @@ bool RsDirUtil::checkDirectory(const std::string& dir)
527527
// mingw64 _wstat fails when the directory name has trailing slash or backslash: we remove them
528528
while (!fixed.empty() && (fixed.back() == '\\' || fixed.back() == '/'))
529529
fixed.pop_back();
530+
// Restore separator for Windows drive roots: "C:" alone means the
531+
// current working directory on drive C, not the root of the drive.
532+
if (fixed.size() == 2 && fixed[1] == ':' && isalpha(fixed[0]))
533+
fixed += '\\';
530534
librs::util::ConvertUtf8ToUtf16(fixed, wdir);
531535
struct _stat buf;
532536
val = _wstat(wdir.c_str(), &buf);

0 commit comments

Comments
 (0)