Skip to content

fix: handle Windows drive root paths (C:/) in shared directories to prevent 0 files shown#279

Merged
csoler merged 2 commits intoRetroShare:masterfrom
jolavillette:FixWindowsDriveRootSharing
Mar 11, 2026
Merged

fix: handle Windows drive root paths (C:/) in shared directories to prevent 0 files shown#279
csoler merged 2 commits intoRetroShare:masterfrom
jolavillette:FixWindowsDriveRootSharing

Conversation

@jolavillette
Copy link
Copy Markdown
Contributor

Problem

On Windows, sharing a drive at its root level (e.g. [C:/] or [D:/]) results in RetroShare displaying 0 shared files. This is a regression introduced by the recent fix for _wstat failing on trailing slashes in [checkDirectory()]

Root cause

Three interacting issues:

  1. [checkDirectory()] — The trailing slash stripping turns [C:/] into [C:], which under Windows API (_wstat) refers to the current working directory on drive C, not the drive root. These are two fundamentally different concepts inherited from DOS.

  2. FolderIterator::updateFileInfo() — The path construction mFolderName + "/" + mFileName produces double slashes (C://file) when iterating a drive root, causing _wstati64 to fail silently on each entry.

  3. [recursUpdateSharedDir()] — Same double-slash issue in 3 manual path concatenations (cumulated_path + "/" + name).

Fix

  • After stripping trailing slashes, restore \ if the result is a bare drive letter ([C:] → C:\)
  • Check if path already ends with a separator before adding one in FolderIterator
  • Replace 3 manual concatenations with RsDirUtil::makePath() which already handles trailing separators correctly

Comment thread src/util/folderiterator.cc Outdated
}

mFullPath = mFolderName + "/" + mFileName ;
if(!mFolderName.empty() && (mFolderName.back() == '/' || mFolderName.back() == '\\'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don' tyou use RsDirUtil::makePath() here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jolavillette jolavillette force-pushed the FixWindowsDriveRootSharing branch from e847a9c to a2a697e Compare March 9, 2026 03:56
@csoler csoler merged commit 8f1fc30 into RetroShare:master Mar 11, 2026
1 check failed
@jolavillette jolavillette deleted the FixWindowsDriveRootSharing branch March 18, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants