Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: base/native_library_mac.mm

Issue 19052005: Move PathIsWritable, DirectoryExists, ContentsEqual, and TextContentsEqual to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/json/json_value_serializer_unittest.cc ('k') | base/nix/mime_util_xdg.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/native_library.h" 5 #include "base/native_library.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <mach-o/getsect.h> 8 #include <mach-o/getsect.h>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 27 matching lines...) Expand all
38 reinterpret_cast<const struct mach_header*>(info.dli_fbase), 38 reinterpret_cast<const struct mach_header*>(info.dli_fbase),
39 SEG_OBJC, "__image_info"); 39 SEG_OBJC, "__image_info");
40 #endif 40 #endif
41 return section == NULL ? OBJC_NOT_PRESENT : OBJC_PRESENT; 41 return section == NULL ? OBJC_NOT_PRESENT : OBJC_PRESENT;
42 } 42 }
43 43
44 // static 44 // static
45 NativeLibrary LoadNativeLibrary(const base::FilePath& library_path, 45 NativeLibrary LoadNativeLibrary(const base::FilePath& library_path,
46 std::string* error) { 46 std::string* error) {
47 // dlopen() etc. open the file off disk. 47 // dlopen() etc. open the file off disk.
48 if (library_path.Extension() == "dylib" || 48 if (library_path.Extension() == "dylib" || !DirectoryExists(library_path)) {
49 !file_util::DirectoryExists(library_path)) {
50 void* dylib = dlopen(library_path.value().c_str(), RTLD_LAZY); 49 void* dylib = dlopen(library_path.value().c_str(), RTLD_LAZY);
51 if (!dylib) 50 if (!dylib)
52 return NULL; 51 return NULL;
53 NativeLibrary native_lib = new NativeLibraryStruct(); 52 NativeLibrary native_lib = new NativeLibraryStruct();
54 native_lib->type = DYNAMIC_LIB; 53 native_lib->type = DYNAMIC_LIB;
55 native_lib->dylib = dylib; 54 native_lib->dylib = dylib;
56 native_lib->objc_status = OBJC_UNKNOWN; 55 native_lib->objc_status = OBJC_UNKNOWN;
57 return native_lib; 56 return native_lib;
58 } 57 }
59 base::ScopedCFTypeRef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation( 58 base::ScopedCFTypeRef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 116
118 return function_pointer; 117 return function_pointer;
119 } 118 }
120 119
121 // static 120 // static
122 string16 GetNativeLibraryName(const string16& name) { 121 string16 GetNativeLibraryName(const string16& name) {
123 return name + ASCIIToUTF16(".dylib"); 122 return name + ASCIIToUTF16(".dylib");
124 } 123 }
125 124
126 } // namespace base 125 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_value_serializer_unittest.cc ('k') | base/nix/mime_util_xdg.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698