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

Side by Side Diff: base/native_library_mac.mm

Issue 6864020: linux: don't always print dlopen errors from LoadNativeLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 // static 18 // static
19 NativeLibrary LoadNativeLibrary(const FilePath& library_path) { 19 NativeLibrary LoadNativeLibrary(const FilePath& library_path,
20 std::string* error) {
20 // dlopen() etc. open the file off disk. 21 // dlopen() etc. open the file off disk.
21 if (library_path.Extension() == "dylib" || 22 if (library_path.Extension() == "dylib" ||
22 !file_util::DirectoryExists(library_path)) { 23 !file_util::DirectoryExists(library_path)) {
23 void* dylib = dlopen(library_path.value().c_str(), RTLD_LAZY); 24 void* dylib = dlopen(library_path.value().c_str(), RTLD_LAZY);
24 if (!dylib) 25 if (!dylib)
awong 2011/04/15 18:57:01 Shouldn't this also grab dlerror()? The mac libra
Evan Martin 2011/04/15 19:00:04 I figured I wouldn't try to change behavior. And
25 return NULL; 26 return NULL;
26 NativeLibrary native_lib = new NativeLibraryStruct(); 27 NativeLibrary native_lib = new NativeLibraryStruct();
27 native_lib->type = DYNAMIC_LIB; 28 native_lib->type = DYNAMIC_LIB;
28 native_lib->dylib = dylib; 29 native_lib->dylib = dylib;
29 return native_lib; 30 return native_lib;
30 } 31 }
31 base::mac::ScopedCFTypeRef<CFURLRef> url( 32 base::mac::ScopedCFTypeRef<CFURLRef> url(
32 CFURLCreateFromFileSystemRepresentation( 33 CFURLCreateFromFileSystemRepresentation(
33 kCFAllocatorDefault, 34 kCFAllocatorDefault,
34 (const UInt8*)library_path.value().c_str(), 35 (const UInt8*)library_path.value().c_str(),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 71 }
71 return dlsym(library->dylib, name); 72 return dlsym(library->dylib, name);
72 } 73 }
73 74
74 // static 75 // static
75 string16 GetNativeLibraryName(const string16& name) { 76 string16 GetNativeLibraryName(const string16& name) {
76 return name + ASCIIToUTF16(".dylib"); 77 return name + ASCIIToUTF16(".dylib");
77 } 78 }
78 79
79 } // namespace base 80 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698