Skip to content

Commit

Permalink
* add base_paths_mac.mm to mac port
Browse files Browse the repository at this point in the history
* add file_util_posix.cc to mac port (NOTE: untested on linux)
* a bit of cleanup in path_service.cc related to this
* a few more cleanups to file_util.cc to make it build for mac

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@589 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
erikkay@google.com committed Aug 8, 2008
1 parent 764be58 commit 5af2edb
Show file tree
Hide file tree
Showing 10 changed files with 644 additions and 71 deletions.
40 changes: 30 additions & 10 deletions base/base.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@
829E365F0DC0FB1C00819EBF /* stats_table.cc in Sources */ = {isa = PBXBuildFile; fileRef = 825403790D92D2CF0006B936 /* stats_table.cc */; };
829E36730DC0FBAD00819EBF /* thread_local_storage_posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = 829E36720DC0FBAD00819EBF /* thread_local_storage_posix.cc */; };
829E36740DC0FBB100819EBF /* thread_local_storage.h in Headers */ = {isa = PBXBuildFile; fileRef = 825403820D92D2CF0006B936 /* thread_local_storage.h */; };
A5A026190E48FE1500498DA9 /* base_paths_mac.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A026180E48FE1500498DA9 /* base_paths_mac.h */; };
A5A0261F0E48FF2200498DA9 /* path_service.cc in Sources */ = {isa = PBXBuildFile; fileRef = A5A0261E0E48FF2200498DA9 /* path_service.cc */; };
A5A026550E4A214600498DA9 /* file_util.cc in Sources */ = {isa = PBXBuildFile; fileRef = A5A026540E4A214600498DA9 /* file_util.cc */; };
A5A0268E0E4A2BDC00498DA9 /* file_util_posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = A5A0268D0E4A2BDC00498DA9 /* file_util_posix.cc */; };
A5A0270B0E4A630D00498DA9 /* file_util_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5A0270A0E4A630D00498DA9 /* file_util_mac.mm */; };
A5A0276C0E4BA33700498DA9 /* build_config.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A0276B0E4BA33700498DA9 /* build_config.h */; };
ABF4B98F0DC2BA6900A6E319 /* base_paths_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABF4B98E0DC2BA6900A6E319 /* base_paths_mac.mm */; };
ABF4B99E0DC2BB6000A6E319 /* clipboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABF4B99D0DC2BB6000A6E319 /* clipboard.mm */; };
ABF4B9A70DC2BBAE00A6E319 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 829E31330DBFDB6F00819EBF /* CoreGraphics.framework */; };
ABF4B9AA0DC2BC2A00A6E319 /* file_util_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABF4B9A90DC2BC2A00A6E319 /* file_util_mac.cc */; };
ABF4B9AD0DC2BC4800A6E319 /* file_version_info.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABF4B9AC0DC2BC4800A6E319 /* file_version_info.mm */; };
ABF4B9AF0DC2BC6200A6E319 /* json_reader.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8254031B0D92D1F40006B936 /* json_reader.cc */; };
ABF4B9B00DC2BC6500A6E319 /* json_writer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8254031D0D92D1F40006B936 /* json_writer.cc */; };
Expand Down Expand Up @@ -254,42 +259,42 @@
isa = PBXContainerItemProxy;
containerPortal = E45A2C680E47AEFF00DB1196 /* gtest.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = D2AAC045055464E500DB518D /* gtest */;
remoteGlobalIDString = D2AAC045055464E500DB518D;
remoteInfo = gtest;
};
E49F18C60E4CBAED00386AEC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E4562AF30E27E428005E4685 /* icu.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 7BD5408A0D6F743F003CD41E /* icudata_stub */;
remoteGlobalIDString = 7BD5408A0D6F743F003CD41E;
remoteInfo = icudata_stub;
};
E49F18C80E4CBAED00386AEC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E4562AF30E27E428005E4685 /* icu.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 7BD53AAA0D6F6671003CD41E /* icuuc */;
remoteGlobalIDString = 7BD53AAA0D6F6671003CD41E;
remoteInfo = icuuc;
};
E49F18CA0E4CBAED00386AEC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E4562AF30E27E428005E4685 /* icu.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 7BD53EA50D6F6FC7003CD41E /* icui18n */;
remoteGlobalIDString = 7BD53EA50D6F6FC7003CD41E;
remoteInfo = icui18n;
};
E49F18CC0E4CBAED00386AEC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E4562AF30E27E428005E4685 /* icu.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 7BD540250D6F727B003CD41E /* icutu */;
remoteGlobalIDString = 7BD540250D6F727B003CD41E;
remoteInfo = icutu;
};
E49F18CE0E4CBAED00386AEC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E4562AF30E27E428005E4685 /* icu.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 82C262C30DCF9411005CFE91 /* icudatastatic */;
remoteGlobalIDString = 82C262C30DCF9411005CFE91;
remoteInfo = icudatastatic;
};
/* End PBXContainerItemProxy section */
Expand Down Expand Up @@ -452,9 +457,14 @@
829E36720DC0FBAD00819EBF /* thread_local_storage_posix.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = thread_local_storage_posix.cc; sourceTree = "<group>"; };
82E23FCB0D9C219600F8B40A /* platform_thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform_thread.h; sourceTree = "<group>"; };
82E23FCC0D9C219600F8B40A /* platform_thread.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = platform_thread.cc; sourceTree = "<group>"; };
A5A026180E48FE1500498DA9 /* base_paths_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base_paths_mac.h; sourceTree = "<group>"; };
A5A0261E0E48FF2200498DA9 /* path_service.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = path_service.cc; sourceTree = "<group>"; };
A5A026540E4A214600498DA9 /* file_util.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_util.cc; sourceTree = "<group>"; };
A5A0268D0E4A2BDC00498DA9 /* file_util_posix.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_util_posix.cc; sourceTree = "<group>"; };
A5A0270A0E4A630D00498DA9 /* file_util_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = file_util_mac.mm; sourceTree = "<group>"; };
A5A0276B0E4BA33700498DA9 /* build_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = build_config.h; path = ../build/build_config.h; sourceTree = SOURCE_ROOT; };
ABF4B98E0DC2BA6900A6E319 /* base_paths_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = base_paths_mac.mm; sourceTree = "<group>"; };
ABF4B99D0DC2BB6000A6E319 /* clipboard.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = clipboard.mm; sourceTree = "<group>"; };
ABF4B9A90DC2BC2A00A6E319 /* file_util_mac.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_util_mac.cc; sourceTree = "<group>"; };
ABF4B9AC0DC2BC4800A6E319 /* file_version_info.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = file_version_info.mm; sourceTree = "<group>"; };
ABF4B9B40DC2BC9F00A6E319 /* path_service.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = path_service.cc; sourceTree = "<group>"; };
E45629E40E27C058005E4685 /* rect_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rect_unittest.cc; sourceTree = "<group>"; };
Expand Down Expand Up @@ -536,6 +546,11 @@
825402B60D92D0E20006B936 /* base */ = {
isa = PBXGroup;
children = (
A5A0270A0E4A630D00498DA9 /* file_util_mac.mm */,
A5A0268D0E4A2BDC00498DA9 /* file_util_posix.cc */,
A5A026540E4A214600498DA9 /* file_util.cc */,
A5A0261E0E48FF2200498DA9 /* path_service.cc */,
A5A026180E48FE1500498DA9 /* base_paths_mac.h */,
E49115EB0E47B461001EE8C3 /* at_exit.h */,
E49115EC0E47B461001EE8C3 /* at_exit.cc */,
E49115F30E47B496001EE8C3 /* at_exit_unittest.cc */,
Expand All @@ -550,6 +565,7 @@
825402CD0D92D1390006B936 /* basictypes.h */,
825402D70D92D15E0006B936 /* blapi.h */,
825402D80D92D15E0006B936 /* blapit.h */,
A5A0276B0E4BA33700498DA9 /* build_config.h */,
825402DB0D92D1730006B936 /* clipboard.h */,
ABF4B99D0DC2BB6000A6E319 /* clipboard.mm */,
825402DD0D92D1730006B936 /* clipboard_util.h */,
Expand All @@ -566,7 +582,6 @@
825402FF0D92D1BC0006B936 /* event_recorder.cc */,
825403000D92D1BC0006B936 /* event_recorder.h */,
825403030D92D1C50006B936 /* file_util.h */,
ABF4B9A90DC2BC2A00A6E319 /* file_util_mac.cc */,
E4562AB10E27D8D7005E4685 /* file_version_info_unittest.cc */,
825403070D92D1CD0006B936 /* file_version_info.h */,
ABF4B9AC0DC2BC4800A6E319 /* file_version_info.mm */,
Expand Down Expand Up @@ -844,8 +859,10 @@
E48A066B0E3F70B500172919 /* convolver.h in Headers */,
E49357230E422A38008F8B09 /* timer.h in Headers */,
E49115EE0E47B461001EE8C3 /* at_exit.h in Headers */,
A5A026190E48FE1500498DA9 /* base_paths_mac.h in Headers */,
7B4C5D890E4915D800679E8F /* float_util.h in Headers */,
7B4C5F490E4B6BF900679E8F /* sys_string_conversions.h in Headers */,
A5A0276C0E4BA33700498DA9 /* build_config.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1093,7 +1110,6 @@
824655DD0DC659B8007C2BAA /* word_iterator.cc in Sources */,
ABF4B98F0DC2BA6900A6E319 /* base_paths_mac.mm in Sources */,
ABF4B99E0DC2BB6000A6E319 /* clipboard.mm in Sources */,
ABF4B9AA0DC2BC2A00A6E319 /* file_util_mac.cc in Sources */,
ABF4B9AD0DC2BC4800A6E319 /* file_version_info.mm in Sources */,
ABF4B9AF0DC2BC6200A6E319 /* json_reader.cc in Sources */,
ABF4B9B00DC2BC6500A6E319 /* json_writer.cc in Sources */,
Expand All @@ -1118,6 +1134,10 @@
E45062A60E40A9BE0025A81A /* base_switches.cc in Sources */,
E49357220E422A36008F8B09 /* timer.cc in Sources */,
E49115EF0E47B461001EE8C3 /* at_exit.cc in Sources */,
A5A0261F0E48FF2200498DA9 /* path_service.cc in Sources */,
A5A026550E4A214600498DA9 /* file_util.cc in Sources */,
A5A0268E0E4A2BDC00498DA9 /* file_util_posix.cc in Sources */,
A5A0270B0E4A630D00498DA9 /* file_util_mac.mm in Sources */,
7B4C5F4A0E4B6BF900679E8F /* sys_string_conversions_mac.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
10 changes: 6 additions & 4 deletions base/base_paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef BASE_BASE_PATHS_H__
#define BASE_BASE_PATHS_H__
#ifndef BASE_BASE_PATHS_H_
#define BASE_BASE_PATHS_H_

// This file declares path keys for the base module. These can be used with
// the PathService to access various special directories and files.

#include "base/basictypes.h"
#ifdef OS_WIN
#if defined(OS_WIN)
#include "base/base_paths_win.h"
#elif defined(OS_MACOSX)
#include "base/base_paths_mac.h"
#endif

namespace base {
Expand All @@ -55,4 +57,4 @@ enum {

} // namespace base

#endif // BASE_BASE_PATHS_H__
#endif // BASE_BASE_PATHS_H_
54 changes: 54 additions & 0 deletions base/base_paths_mac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef BASE_BASE_PATHS_MAC_H_
#define BASE_BASE_PATHS_MAC_H_

// This file declares Mac-specific path keys for the base module.
// These can be used with the PathService to access various special
// directories and files.

namespace base {

enum {
PATH_MAC_START = 200,

FILE_EXE, // path and filename of the current executable
FILE_MODULE, // path and filename of the module containing the code for the
// PathService (which could differ from FILE_EXE if the
// PathService were compiled into a DLL, for example)
DIR_APP_DATA, // Application Data directory under the user profile.
DIR_LOCAL_APP_DATA, // "Local Settings\Application Data" directory under the
// user profile.
PATH_MAC_END
};

} // namespace base

#endif // BASE_BASE_PATHS_MAC_H_
73 changes: 73 additions & 0 deletions base/base_paths_mac.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copied from base/basictypes.h with some modifications

#include "base/base_paths_mac.h"

#import <Cocoa/Cocoa.h>

#include "base/logging.h"
#include "base/string_util.h"

namespace base {

bool PathProviderMac(int key, std::wstring* result) {
std::wstring cur;
switch (key) {
case base::FILE_EXE:
case base::FILE_MODULE: {
NSString* path = [[NSBundle mainBundle] executablePath];
cur = reinterpret_cast<const wchar_t*>(
[path cStringUsingEncoding:NSUTF32StringEncoding]);
break;
}
case base::DIR_APP_DATA:
case base::DIR_LOCAL_APP_DATA: {
// TODO(erikkay): maybe we should remove one of these for mac? The local
// vs. roaming distinction is fairly Windows-specific.
NSArray* dirs = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
if (!dirs || [dirs count] == 0)
return false;
DCHECK([dirs count] == 1);
NSString* tail = [[NSString alloc] initWithCString:"Google/Chrome"];
NSString* path = [[dirs lastObject] stringByAppendingPathComponent:tail];
cur = reinterpret_cast<const wchar_t*>(
[path cStringUsingEncoding:NSUTF32StringEncoding]);
break;
}
default:
return false;
}

result->swap(cur);
return true;
}

} // namespace base
Loading

0 comments on commit 5af2edb

Please sign in to comment.