Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #313 from adobe/jeff/fix-delete-folder-win-xp-rb
Browse files Browse the repository at this point in the history
Fixes delete folder on XP
  • Loading branch information
gruehle committed Aug 26, 2013
2 parents a7871db + 30160e2 commit b23dfc8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions appshell/appshell_extensions_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
// Forward declarations for functions at the bottom of this file
void ConvertToNativePath(ExtensionString& filename);
void ConvertToUnixPath(ExtensionString& filename);
void RemoveTrailingSlash(ExtensionString& filename);
int ConvertErrnoCode(int errorCode, bool isReading = true);
int ConvertWinErrorCode(int errorCode, bool isReading = true);
static std::wstring GetPathToLiveBrowser();
Expand Down Expand Up @@ -763,8 +764,18 @@ int32 ShellDeleteFileOrDirectory(ExtensionString filename, bool allowUndo)
return ERR_NOT_FOUND;
}

// Windows XP doesn't like Posix Paths
// It will work but the filenames in the recycle
// bin are hidden so convert to a native path.
ConvertToNativePath(filename);

// Windows XP doesn't like directory names
// that end with a trailing slash so remove it
RemoveTrailingSlash(filename);

WCHAR filepath[MAX_PATH+1] = {0};
wcscpy(filepath, filename.c_str());

SHFILEOPSTRUCT operation = {0};

operation.wFunc = FO_DELETE;
Expand Down Expand Up @@ -836,6 +847,16 @@ void ConvertToUnixPath(ExtensionString& filename)
replace(filename.begin(), filename.end(), '\\', '/');
}

bool isSlash(ExtensionString::value_type wc) { return wc == '/' || wc == '\\'; }

void RemoveTrailingSlash(ExtensionString& filename)
{
int last = filename.length() - 1;
if ((last >= 0) && isSlash(filename.at(last))) {
filename.erase(last);
}
}

// Maps errors from errno.h to the brackets error codes
// found in brackets_extensions.js
int ConvertErrnoCode(int errorCode, bool isReading)
Expand Down

0 comments on commit b23dfc8

Please sign in to comment.