From 4b22fe23eeb0dce4f47f4b7521fca046d505c4bd Mon Sep 17 00:00:00 2001 From: koldo Date: Tue, 7 Sep 2010 20:48:52 +0000 Subject: [PATCH] Functions4U: Some improvements in LaunchFile, added UpperFolder and Dl (old DLL) now in Linux too git-svn-id: svn://ultimatepp.org/upp/trunk@2664 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/Functions4U/Functions4U.cpp | 24 ++++++++++++------- bazaar/Functions4U/Functions4U.h | 3 ++- .../Functions4U/src.tpp/Functions4U$en-us.tpp | 6 ++--- bazaar/Functions4U/src.tpp/all.i | 4 ---- .../srcdoc.tpp/ChangesLog$en-us.tpp | 5 +++- bazaar/Functions4U/srcdoc.tpp/all.i | 4 ---- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/bazaar/Functions4U/Functions4U.cpp b/bazaar/Functions4U/Functions4U.cpp index 6ca7d0220..c224ba5f8 100644 --- a/bazaar/Functions4U/Functions4U.cpp +++ b/bazaar/Functions4U/Functions4U.cpp @@ -1115,7 +1115,7 @@ String GetNextFolder(String folder, String lastFolder) { return lastFolder; } -bool ThereIsUpperFolder(String folderName) { +bool UpperFolder(String folderName) { if (folderName.IsEmpty()) return false; #ifdef PLATFORM_WIN32 @@ -1128,7 +1128,7 @@ bool ThereIsUpperFolder(String folderName) { } String GetUpperFolder(String folderName) { - if (!ThereIsUpperFolder(folderName)) + if (!UpperFolder(folderName)) return folderName; int len = folderName.GetCount(); if (folderName[len-1] == DIR_SEP) @@ -1861,13 +1861,7 @@ Value GetVARIANT(VARIANT &result) ret = dbcs; */ { - int len = WideCharToMultiByte(CP_UTF8, 0, result.bstrVal, -1, NULL, 0, NULL, NULL); - if (len == 0) - return Null; - Buffer w; - w.Alloc(len); - WideCharToMultiByte(CP_UTF8, 0, result.bstrVal, -1, w, len, NULL, NULL); - ret = ~w; + ret = WideToString(result.bstrVal); break; } case VT_LPSTR: @@ -1893,6 +1887,18 @@ Value GetVARIANT(VARIANT &result) } return ret; } + +String WideToString(LPCWSTR wcs, int len) { + if (len == -1) { + len = WideCharToMultiByte(CP_UTF8, 0, wcs, len, NULL, 0, NULL, NULL); + if (len == 0) + return Null; + } + Buffer w(len); + WideCharToMultiByte(CP_UTF8, 0, wcs, len, w, len, NULL, NULL); + return ~w; +} + #endif #if defined(PLATFORM_WIN32) diff --git a/bazaar/Functions4U/Functions4U.h b/bazaar/Functions4U/Functions4U.h index 9edd0ab13..cd4229068 100644 --- a/bazaar/Functions4U/Functions4U.h +++ b/bazaar/Functions4U/Functions4U.h @@ -33,7 +33,7 @@ bool DirectoryCopyX(const char *dir, const char *newPlace); bool DeleteFolderDeepWildcards(const char *dir, int flags = 0); /////////////////////////////// -bool ThereIsUpperFolder(String folderName); +bool UpperFolder(String folderName); String GetUpperFolder(String folderName); String GetNextFolder(String folder, String lastFolder); String GetRealName(String fileName); @@ -436,6 +436,7 @@ private: #if defined(PLATFORM_WIN32) Value GetVARIANT(VARIANT &result); +String WideToString(LPCWSTR wcs, int len = -1); #endif #ifdef CTRLLIB_H diff --git a/bazaar/Functions4U/src.tpp/Functions4U$en-us.tpp b/bazaar/Functions4U/src.tpp/Functions4U$en-us.tpp index bfd461c31..ad9881854 100644 --- a/bazaar/Functions4U/src.tpp/Functions4U$en-us.tpp +++ b/bazaar/Functions4U/src.tpp/Functions4U$en-us.tpp @@ -54,8 +54,8 @@ olderName])&] [s2; Returns the name of the folder over [%-*@3 folderName].&] [s3; &] [s4;%- &] -[s5;:ThereIsUpperFolder`(String`):%- [@(0.0.255) bool]_[* ThereIsUpperFolder]([_^String^ St -ring]_[*@3 folderName])&] +[s5;:UpperFolder`(String`):%- [@(0.0.255) bool]_[* UpperFolder]([_^String^ String]_[*@3 folde +rName])&] [s0;l288; Returns true if there is a folder over [%-*@3 folderName].&] [s3; &] [s4;%- &] @@ -70,7 +70,7 @@ ing]_[*@3 folder], [_^String^ String]_[*@3 lastFolder])&] [s2; Considering [%-*@3 folder ]as a parent folder of [%-*@3 lastFolder], it returns the folder under [%-*@3 folder ]that is also parent of [%-*@3 lastFolder].&] -[s0;l288; For example: GetNextFolder(`"/home`", `"/home/user/documents`") +[s2; For example: GetNextFolder(`"/home`", `"/home/user/documents`") returns `"/home/user`".&] [s3; &] [s4;%- &] diff --git a/bazaar/Functions4U/src.tpp/all.i b/bazaar/Functions4U/src.tpp/all.i index d5e3c3192..e1fa5ecf4 100644 --- a/bazaar/Functions4U/src.tpp/all.i +++ b/bazaar/Functions4U/src.tpp/all.i @@ -6,10 +6,6 @@ TOPIC("Dll$en-us") #include "Dll$en-us.tppi" END_TOPIC -TOPIC("Functions4U$en-us") -#include "Functions4U$en-us.tppi" -END_TOPIC - TOPIC("SvgColors$en-us") #include "SvgColors$en-us.tppi" END_TOPIC diff --git a/bazaar/Functions4U/srcdoc.tpp/ChangesLog$en-us.tpp b/bazaar/Functions4U/srcdoc.tpp/ChangesLog$en-us.tpp index 494670560..eea8e8ee2 100644 --- a/bazaar/Functions4U/srcdoc.tpp/ChangesLog$en-us.tpp +++ b/bazaar/Functions4U/srcdoc.tpp/ChangesLog$en-us.tpp @@ -4,7 +4,10 @@ topic "News and changes Log"; [{_}%EN-US [s0; [*R+184 Functions4U. News and changes log]&] [s0;%- &] -[ {{1441:8559f0;g0;^t/25b/25 [s0;# [2 2010/07/27]] +[ {{1441:8559f0;g0;^t/25b/25 [s0;# [2 2010/09/07]] +:: [s0;# [2 Some improvements in LaunchFile, added UpperFolder and Dl +(DLL) now in Linux too.]] +:: [s0;# [2 2010/07/27]] :: [s0;# [2 Added String Replace(String str, char find, char replace).]] :: [s0;# [2 2010/07/19]] :: [s0;# [2 Removed las Xmlize and GridCtrl function. Now all are in Core diff --git a/bazaar/Functions4U/srcdoc.tpp/all.i b/bazaar/Functions4U/srcdoc.tpp/all.i index 6bd16d038..65dcd7bc5 100644 --- a/bazaar/Functions4U/srcdoc.tpp/all.i +++ b/bazaar/Functions4U/srcdoc.tpp/all.i @@ -1,7 +1,3 @@ -TOPIC("ChangesLog$en-us") -#include "ChangesLog$en-us.tppi" -END_TOPIC - TOPIC("Functions4U$en-us") #include "Functions4U$en-us.tppi" END_TOPIC