Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/common/utility_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ void Utility::setupDesktopIni(const QString &folder, const QString localizedReso
desktopIni.write("\r\n");
desktopIni.close();

// Set the folder as system and Desktop.ini as hidden+system for explorer to pick it.
// Set the folder as read only and Desktop.ini as hidden+system for explorer to pick it.
// https://msdn.microsoft.com/en-us/library/windows/desktop/cc144102
DWORD folderAttrs = GetFileAttributesW((wchar_t *)folder.utf16());
SetFileAttributesW((wchar_t *)folder.utf16(), folderAttrs | FILE_ATTRIBUTE_SYSTEM);
SetFileAttributesW((wchar_t *)folder.utf16(), folderAttrs | FILE_ATTRIBUTE_READONLY);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if the folder was already setup to use system flag ?

SetFileAttributesW((wchar_t *)desktopIni.fileName().utf16(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
}

Expand Down Expand Up @@ -234,8 +234,8 @@ void Utility::removeFavLink(const QString &folder)

// #2 Remove the system file attribute
const auto folderAttrs = GetFileAttributesW(folder.toStdWString().c_str());
if (!SetFileAttributesW(folder.toStdWString().c_str(), folderAttrs & ~FILE_ATTRIBUTE_SYSTEM)) {
qCWarning(lcUtility) << "Remove system file attribute failed for:" << folder;
if (!SetFileAttributesW(folder.toStdWString().c_str(), folderAttrs & ~FILE_ATTRIBUTE_READONLY)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what would happen if this folder was using the system flags ?
we would need to care about existing users

qCWarning(lcUtility) << "Remove read only file attribute failed for:" << folder;
}

// #3 Remove the link to this folder
Expand Down