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 #281 from adobe/rlim/crash-issue-4410
Browse files Browse the repository at this point in the history
isNetworkDrive API returns an error if the path for network drive detection does not exist.
  • Loading branch information
gruehle committed Jul 17, 2013
2 parents efed8c1 + 9160b05 commit fdea13a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion appshell/appshell_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ if (!appshell.app) {
* Possible error values:
* NO_ERROR
* ERR_INVALID_PARAMS
*
* ERR_NOT_FOUND
*
* @return None. This is an asynchronous call that sends all return information to the callback.
*/
native function IsNetworkDrive();
Expand Down
5 changes: 5 additions & 0 deletions appshell/appshell_extensions_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ int32 IsNetworkDrive(ExtensionString path, bool& isRemote)
return ERR_INVALID_PARAMS;
}

// No need to detect network drive if the path does not exist.
if (![[NSFileManager defaultManager] fileExistsAtPath:pathStr]) {
return ERR_NOT_FOUND;
}

// Detect remote drive
NSString *testPath = [pathStr copy];
while (![testPath isEqualToString:@"/"]) {
Expand Down
5 changes: 5 additions & 0 deletions appshell/appshell_extensions_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@ int32 IsNetworkDrive(ExtensionString path, bool& isRemote)
return ERR_INVALID_PARAMS;
}

DWORD dwAttr;
dwAttr = GetFileAttributes(path.c_str());
if (INVALID_FILE_ATTRIBUTES == dwAttr)
return ConvertWinErrorCode(GetLastError());

ExtensionString drive = path.substr(0, path.find('/') + 1);
isRemote = GetDriveType(drive.c_str()) == DRIVE_REMOTE;

Expand Down

0 comments on commit fdea13a

Please sign in to comment.