From 24bd82a92fe13040e9d7e2ca1942043ed5931754 Mon Sep 17 00:00:00 2001 From: Brian Swetland Date: Thu, 4 Jun 2009 14:04:53 -0700 Subject: [PATCH] localize: remove dependency on mkdirs/etc in libhost This will let us break the libhost dependency on libutils. Signed-off-by: Brian Swetland --- tools/localize/Android.mk | 1 - tools/localize/file_utils.cpp | 36 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tools/localize/Android.mk b/tools/localize/Android.mk index 186177f53638a..ab79f8dbdcfcb 100644 --- a/tools/localize/Android.mk +++ b/tools/localize/Android.mk @@ -53,4 +53,3 @@ ifeq (a,a) endif include $(BUILD_HOST_EXECUTABLE) - diff --git a/tools/localize/file_utils.cpp b/tools/localize/file_utils.cpp index bb82a9c55f142..8792b9e54d3d7 100644 --- a/tools/localize/file_utils.cpp +++ b/tools/localize/file_utils.cpp @@ -3,12 +3,46 @@ #include #include "file_utils.h" #include "Perforce.h" +#include #include #include #include -#include #include "log.h" +using namespace android; +using namespace std; + +static string +parent_dir(const string& path) +{ + return string(String8(path.c_str()).getPathDir().string()); +} + +static int +mkdirs(const char* last) +{ + String8 dest; + const char* s = last-1; + int err; + do { + s++; + if (s > last && (*s == '.' || *s == 0)) { + String8 part(last, s-last); + dest.appendPath(part); +#ifdef HAVE_MS_C_RUNTIME + err = _mkdir(dest.string()); +#else + err = mkdir(dest.string(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP); +#endif + if (err != 0) { + return err; + } + last = s+1; + } + } while (*s); + return 0; +} + string translated_file_name(const string& file, const string& locale) {