Hello playmobil,
I'd like you to do a code review. Please execute
g4 diff -c 9209779
or point your web browser to
http://mondrian/9209779
to review the following code:
Change 9209779 by [EMAIL PROTECTED] on 2008/12/01 18:26:52 *pending*
Follow alias files, for Safari's Drag and Drop. This mimics what
Firefox/OSX does, and also what IE/Windows does (in following .lnk)
files.
PRESUBMIT=passed
R=playmobil
[EMAIL PROTECTED]
DELTA=33 (32 added, 0 deleted, 1 changed)
OCL=9209779
Affected files ...
...
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm#4
edit
33 delta lines: 32 added, 0 deleted, 1 changed
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 9209779 by [EMAIL PROTECTED] on 2008/12/01 18:26:52 *pending*
Follow alias files, for Safari's Drag and Drop. This mimics what
Firefox/OSX does, and also what IE/Windows does (in following .lnk)
files.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm#4
edit
====
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm#4
-
/Users/nigeltao/devel/srcmacgears2/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm
====
# action=edit type=text
--- googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm
2008-12-01 13:36:46.000000000 +1100
+++ googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm
2008-12-01 18:10:47.000000000 +1100
@@ -47,6 +47,38 @@
return g_is_in_a_drop_operation;
}
+// This function is based on http://developer.apple.com/documentation/Cocoa/
+// Conceptual/LowLevelFileMgmt/Tasks/ResolvingAliases.html
+void ResolveAlias(NSString *path, std::string16 *resolved_path_out) {
+ NSString *resolved_path = path;
+ CFURLRef url = CFURLCreateWithFileSystemPath(
+ kCFAllocatorDefault, (CFStringRef)path, kCFURLPOSIXPathStyle, NO);
+ if (url != NULL){
+ FSRef fs_ref;
+ if (CFURLGetFSRef(url, &fs_ref)){
+ Boolean ignored, was_aliased;
+ OSErr err = FSResolveAliasFile(&fs_ref, true, &ignored, &was_aliased);
+ if ((err == noErr) && was_aliased) {
+ CFURLRef resolved_url =
+ CFURLCreateFromFSRef(kCFAllocatorDefault, &fs_ref);
+ if (resolved_url != NULL) {
+ resolved_path = (NSString*)
+ CFURLCopyFileSystemPath(resolved_url, kCFURLPOSIXPathStyle);
+ CFRelease(resolved_url);
+ }
+ }
+ }
+ CFRelease(url);
+ }
+ [resolved_path string16:resolved_path_out];
+ if (resolved_path != path) {
+ // If resolved_path is different, then it must have been set to the result
+ // of CFURLCopyFileSystemPath, and since it is a copy, we should release
+ // it when we're done with it.
+ CFRelease(resolved_path);
+ }
+}
+
// We "swizzle" some Cocoa method implementations to insert a little code
// before and after certain events get processed. For more, see
// http://www.cocoadev.com/index.pl?MethodSwizzling
@@ -109,7 +141,7 @@
NSString *ns_string;
while ((ns_string = [enumerator nextObject])) {
std::string16 std_string;
- [ns_string string16:&std_string];
+ ResolveAlias(ns_string, &std_string);
g_dragging_pasteboard_filenames.push_back(std_string);
}
}