From 76c256880e4f316c2cf1573871ee2bee7921356e Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 28 Apr 2010 21:49:03 +0000 Subject: [PATCH] Added win32 version of glob to allow windows clients the ability to do unix like folder traversal --- mk/windoze/Glest.suo | Bin 217088 -> 217088 bytes mk/windoze/shared_lib.vcproj | 8 + .../shared_lib/include/platform/win32/glob.h | 166 +++++++ .../shared_lib/sources/platform/win32/glob.c | 455 ++++++++++++++++++ .../sources/platform/win32/platform_util.cpp | 348 +++++++------- 5 files changed, 808 insertions(+), 169 deletions(-) create mode 100644 source/shared_lib/include/platform/win32/glob.h create mode 100644 source/shared_lib/sources/platform/win32/glob.c diff --git a/mk/windoze/Glest.suo b/mk/windoze/Glest.suo index 374adcb4b3f7cb58d1c46436a4ab843bfd6dd170..c374880a761a1a9262651307195431d7c7df4a0d 100755 GIT binary patch delta 15134 zcmbW8dt6mj{`dD<`+x|j2nd9T2Smh6fQt7E$2%&Cw@lL#M9sUXsO8jvrd=#eS>e?1{_iNSN{7!dLE&K=cW2$Av{)Zb9KRcpa$8mhunl+vy5v}1y+Sbif zS5qJ5@!uFx>_$d`4K6p&uj&)IYEF6O(&ff_JGWjsx6(Uh{)&}li@cL6SI(ZV%!H^y zQ{DV!GrVPf1f$$;Zi+q{(F|U6V~mwCC6UU5-%-Ke{_kQYYt>xNwJb5iQU=wu8Xj>8 z)>3Gz@lmn3fXMpp*E!}pkQSGd$UoxO!j)!C+?c3u{_R8@eq}ZDUx;QL($A2MZv@$Pwx<_`x z@9XdMuSva4+0#RHwy8LoWh;KvQT`*7o=|(!tF_s(%IB~5`dXRuW#h~%SNFGZE7V-G zq*JcBck0Jx)|0vZ+#W}wW9t!900mWsw2f!b&nEub;buv8y#Ls=N7Y_mrS>GFu>3a; zy+hf|RF&f2GW~Pctm`>=*b1i?t{ntLLYLn|D&oq5uKW-FARfb`kXLxMIk5H`vtxJ{ zzaIUjN}CtqIL{y}Es)?vl=ZXl{|t4+Z*y);n&%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l?6lniTu3Vw}MyrGtkPdTNE%~gzRe2Ze`in0GxD0VwDymf^3JXPzof?ueF z!zkfj6+5pO4~f4i_LX9s;Xf3+tQhz4H;P?Tj2-R=#e~+`b?jUk#r@41t{^`+f+1N? z#YR%xuGqjXEL|~|VtmhdigTeRC^nel6IHs&it$7r(@%W#OYR$0_h%N#{RiU!CNVmB(_IMfrMKq z&Nn})7%vG=srWV(^1aWJ*q$Q=?tPx(JV0JhY(9m*Rq>q^HgLjn(k>FmUsqu{g>5Rn zM}-v>?j^D9BXN3miGw6w77vk_u^l0Cp}!yn(w(RHBGTV}VJ_Mwb#7L^R*;*YH!*CN zNqjS}%iTz9%y{eS|3NRkxR@%D;s zT<0#L+!WiuI}lFBCF4@D@c<1l_9eC~5;F%Wu))YvjEgjc#KzMZr{i4{k2khJ5x7?Z z8h<&o>S~g#klMLuGqyc?2=;ND#l&^onqG%OTwLNMN9&Bc3`FuR6(vI zH;@MS)kH0!f!~Ul@#Fn#3WYYs`0+7(k*t?uqbQ!Bm_xA&V#$gPQj8ttQ4(9GVjRz- zI6KPFPS)V}6c_zq%U21x_a`V;teBnHWX0TyIfw-|ymJ*}FS$jfo39vGxLh&b&vKO0 zEr#3aFB!k0F^nXw;0Rf*VtjL*V!ZL?=s?nH#qRFH)+lzbV(bz3buwHwN!!xEP5O*V z^s-9Cz4zaWy{Z^@2k)eL?6oS!O&WMz*rgaxse##dk78EEC@}0*tPjO4ox_r0;6>D| zzS)hGCC9UP`p3pW^g*dS*U~+g?nod}1_rZ)Q85kOD8?0M%OUZVG!my|8$x0>fHaiE zHiE>A>;0coG~YXx#5SJ9>A1o2No;``npq*e-}_;)exq1h7bfSL3h>Y{ZS?;DvSHl> diff --git a/mk/windoze/shared_lib.vcproj b/mk/windoze/shared_lib.vcproj index 5c275e0a4..53e3973d0 100755 --- a/mk/windoze/shared_lib.vcproj +++ b/mk/windoze/shared_lib.vcproj @@ -416,6 +416,10 @@ RelativePath="..\..\source\shared_lib\sources\platform\win32\factory_repository.cpp" > + + @@ -730,6 +734,10 @@ + + diff --git a/source/shared_lib/include/platform/win32/glob.h b/source/shared_lib/include/platform/win32/glob.h new file mode 100644 index 000000000..8d6c56d6c --- /dev/null +++ b/source/shared_lib/include/platform/win32/glob.h @@ -0,0 +1,166 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: glob.h + * + * Purpose: Declaration of the glob() API functions and types for the + * Win32 platform. + * + * Created: 13th November 2002 + * Updated: 5th February 2010 + * + * Home: http://synesis.com.au/software/ + * + * Copyright (c) 2002-2010, Matthew Wilson and Synesis Software + * 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 names of Matthew Wilson and Synesis Software nor the names of + * any 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. + * + * ////////////////////////////////////////////////////////////////////// */ + + +/** \file glob.h + * + * Contains the declarations for the glob() API. + */ + +#ifndef SYNSOFT_UNIXEM_INCL_H_GLOB +#define SYNSOFT_UNIXEM_INCL_H_GLOB + +/* ////////////////////////////////////////////////////////////////////// */ + +/** \weakgroup unixem Synesis Software UNIX Emulation for Win32 + * \brief The UNIX emulation library + */ + +/** \weakgroup unixem_glob glob() API + * \ingroup UNIXem unixem + * \brief This API provides facilities for enumerating the file-system contents + * @{ + */ + +/* ////////////////////////////////////////////////////////////////////// */ + +#ifndef _WIN32 +# error This file is only currently defined for compilation on Win32 systems +#endif /* _WIN32 */ + +/* ///////////////////////////////////////////////////////////////////////// + * Constants and definitions + */ + +/* Error codes */ +#define GLOB_NOSPACE (1) /*!< \brief (Error result code:) An attempt to allocate memory failed, or if errno was 0 GLOB_LIMIT was specified in the flags and ARG_MAX patterns were matched. */ +#define GLOB_ABORTED (2) /*!< \brief (Error result code:) The scan was stopped because an error was encountered and either GLOB_ERR was set or (*errfunc)() returned non-zero. */ +#define GLOB_NOMATCH (3) /*!< \brief (Error result code:) The pattern does not match any existing pathname, and GLOB_NOCHECK was not set int flags. */ +#define GLOB_NOSYS (4) /*!< \brief (Error result code:) . */ +#define GLOB_ABEND GLOB_ABORTED /*!< \brief (Error result code:) . */ + +/* Flags */ +#define GLOB_ERR 0x00000001 /*!< \brief Return on read errors. */ +#define GLOB_MARK 0x00000002 /*!< \brief Append a slash to each name. */ +#define GLOB_NOSORT 0x00000004 /*!< \brief Don't sort the names. */ +#define GLOB_DOOFFS 0x00000008 /*!< \brief Insert PGLOB->gl_offs NULLs. Supported from version 1.6 of UNIXem. */ +#define GLOB_NOCHECK 0x00000010 /*!< \brief If nothing matches, return the pattern. Supported from version 1.6 of UNIXem. */ +#define GLOB_APPEND 0x00000020 /*!< \brief Append to results of a previous call. Not currently supported in this implementation. */ +#define GLOB_NOESCAPE 0x00000040 /*!< \brief Backslashes don't quote metacharacters. Has no effect in this implementation, since escaping is not supported. */ + +#define GLOB_PERIOD 0x00000080 /*!< \brief Leading `.' can be matched by metachars. Supported from version 1.6 of UNIXem. */ +#define GLOB_MAGCHAR 0x00000100 /*!< \brief Set in gl_flags if any metachars seen. Supported from version 1.6 of UNIXem. */ +/* #define GLOB_ALTDIRFUNC 0x00000200 */ /*!< \brief Use gl_opendir et al functions. Not currently supported in this implementation. */ +/* #define GLOB_BRACE 0x00000400 */ /*!< \brief Expand "{a,b}" to "a" "b". Not currently supported in this implementation. */ +#define GLOB_NOMAGIC 0x00000800 /*!< \brief If no magic chars, return the pattern. Supported from version 1.6 of UNIXem. */ +#define GLOB_TILDE 0x00001000 /*!< \brief Expand ~user and ~ to home directories. Partially supported from version 1.6 of UNIXem: leading ~ is expanded to %HOMEDRIVE%%HOMEPATH%. */ +#define GLOB_ONLYDIR 0x00002000 /*!< \brief Match only directories. This implementation guarantees to only return directories when this flag is specified. */ +#define GLOB_TILDE_CHECK 0x00004000 /*!< \brief Like GLOB_TILDE but return an GLOB_NOMATCH even if GLOB_NOCHECK specified. Supported from version 1.6 of UNIXem. */ +#define GLOB_ONLYFILE 0x00008000 /*!< \brief Match only files. Supported from version 1.6 of UNIXem. */ +#define GLOB_NODOTSDIRS 0x00010000 /*!< \brief Elide "." and ".." directories from wildcard searches. Supported from version 1.6 of UNIXem. */ +#define GLOB_LIMIT 0x00020000 /*!< \brief Limits the search to the number specified by the caller in gl_matchc. Supported from version 1.6 of UNIXem. */ + +/* ///////////////////////////////////////////////////////////////////////// + * Typedefs + */ + +/** \brief Result structure for glob() + * + * This structure is used by glob() to return the results of the search. + */ +typedef struct +{ + int gl_pathc; /*!< count of total paths so far */ + int gl_matchc; /*!< count of paths matching pattern */ + int gl_offs; /*!< reserved at beginning of gl_pathv */ + int gl_flags; /*!< returned flags */ + char **gl_pathv; /*!< list of paths matching pattern */ +} glob_t; + +/* ///////////////////////////////////////////////////////////////////////// + * API functions + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** \brief Generates pathnames matching a pattern + * + * This function is a pathname generator that implements the rules for + * file name pattern matching used by the UNIX shell. + * + * \param pattern The pattern controlling the search + * \param flags A combination of the GLOB_* flags + * \param errfunc A function that is called each time part of the search processing fails + * \param pglob Pointer to a glob_t structure to receive the search results + * \return 0 on success, otherwise one of the GLOB_* error codes + */ +int glob( char const *pattern + , int flags +#if defined(__COMO__) + , int (*errfunc)(char const *, int) +#else /* ? compiler */ + , const int (*errfunc)(char const *, int) +#endif /* compiler */ + , glob_t *pglob); + +/** \brief Frees the results of a call to glob + * + * This function releases any memory allocated in a call to glob. It must + * always be called for a successful call to glob. + * + * \param pglob Pointer to a glob_t structure to receive the search results + */ +void globfree(glob_t *pglob); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* ////////////////////////////////////////////////////////////////////// */ + +/** @} // end of group unixem_glob */ + +/* ////////////////////////////////////////////////////////////////////// */ + +#endif /* SYNSOFT_UNIXEM_INCL_H_GLOB */ + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/source/shared_lib/sources/platform/win32/glob.c b/source/shared_lib/sources/platform/win32/glob.c new file mode 100644 index 000000000..c50467e01 --- /dev/null +++ b/source/shared_lib/sources/platform/win32/glob.c @@ -0,0 +1,455 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: glob.c + * + * Purpose: Definition of the glob() API functions for the Win32 platform. + * + * Created: 13th November 2002 + * Updated: 6th February 2010 + * + * Home: http://synesis.com.au/software/ + * + * Copyright (c) 2002-2010, Matthew Wilson and Synesis Software + * 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 names of Matthew Wilson and Synesis Software nor the names of + * any 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. + * + * ////////////////////////////////////////////////////////////////////// */ + +/* ///////////////////////////////////////////////////////////////////////// + * Includes + */ + +#include +#include +#include +#include +#include + +#define NUM_ELEMENTS(ar) (sizeof(ar) / sizeof(ar[0])) + +/* ///////////////////////////////////////////////////////////////////////// + * Helper functions + */ + +static char const *strrpbrk(char const *string, char const *strCharSet) +{ + char *part = NULL; + char const *pch; + + for(pch = strCharSet; *pch; ++pch) + { + char *p = strrchr(string, *pch); + + if(NULL != p) + { + if(NULL == part) + { + part = p; + } + else + { + if(part < p) + { + part = p; + } + } + } + } + + return part; +} + +/* ///////////////////////////////////////////////////////////////////////// + * API functions + */ + +/* It gives you back the matched contents of your pattern, so for Win32, the + * directories must be included + */ + +int glob( char const *pattern + , int flags +#if defined(__COMO__) + , int (*errfunc)(char const *, int) +#else /* ? compiler */ + , const int (*errfunc)(char const *, int) +#endif /* compiler */ + , glob_t *pglob) +{ + int result; + char szRelative[1 + _MAX_PATH]; + char const *file_part; + WIN32_FIND_DATAA find_data; + HANDLE hFind; + char *buffer; + char szPattern2[1 + _MAX_PATH]; + char szPattern3[1 + _MAX_PATH]; + char const *effectivePattern = pattern; + char const *leafMost; + const int bMagic = (NULL != strpbrk(pattern, "?*")); + int bNoMagic = 0; + int bMagic0; + size_t maxMatches = ~(size_t)(0); + + assert(NULL != pglob); + + if(flags & GLOB_NOMAGIC) + { + bNoMagic = !bMagic; + } + + if(flags & GLOB_LIMIT) + { + maxMatches = (size_t)pglob->gl_matchc; + } + + if(flags & GLOB_TILDE) + { + /* Check that begins with "~/" */ + if( '~' == pattern[0] && + ( '\0' == pattern[1] || + '/' == pattern[1] || + '\\' == pattern[1])) + { + DWORD dw; + + (void)lstrcpyA(&szPattern2[0], "%HOMEDRIVE%%HOMEPATH%"); + + dw = ExpandEnvironmentStringsA(&szPattern2[0], &szPattern3[0], NUM_ELEMENTS(szPattern3) - 1); + + if(0 != dw) + { + (void)lstrcpynA(&szPattern3[0] + dw - 1, &pattern[1], (int)(NUM_ELEMENTS(szPattern3) - dw)); + szPattern3[NUM_ELEMENTS(szPattern3) - 1] = '\0'; + + effectivePattern = szPattern3; + } + } + } + + file_part = strrpbrk(effectivePattern, "\\/"); + + if(NULL != file_part) + { + leafMost = ++file_part; + + (void)lstrcpyA(szRelative, effectivePattern); + szRelative[file_part - effectivePattern] = '\0'; + } + else + { + szRelative[0] = '\0'; + leafMost = effectivePattern; + } + + bMagic0 = (leafMost == strpbrk(leafMost, "?*")); + + hFind = FindFirstFileA(effectivePattern, &find_data); + buffer = NULL; + + pglob->gl_pathc = 0; + pglob->gl_pathv = NULL; + + if(0 == (flags & GLOB_DOOFFS)) + { + pglob->gl_offs = 0; + } + + if(hFind == INVALID_HANDLE_VALUE) + { + /* If this was a pattern search, and the + * directory exists, then we return 0 + * matches, rather than GLOB_NOMATCH + */ + if( bMagic && + NULL != file_part) + { + result = 0; + } + else + { + if(NULL != errfunc) + { + (void)errfunc(effectivePattern, (int)GetLastError()); + } + + result = GLOB_NOMATCH; + } + } + else + { + int cbCurr = 0; + size_t cbAlloc = 0; + size_t cMatches = 0; + + result = 0; + + do + { + int cch; + size_t new_cbAlloc; + + if( bMagic0 && + 0 == (flags & GLOB_PERIOD)) + { + if('.' == find_data.cFileName[0]) + { + continue; + } + } + + if(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { +#ifdef GLOB_ONLYFILE + if(flags & GLOB_ONLYFILE) + { + continue; + } +#endif /* GLOB_ONLYFILE */ + + if( bMagic0 && + GLOB_NODOTSDIRS == (flags & GLOB_NODOTSDIRS)) + { + /* Pattern must begin with '.' to match either dots directory */ + if( 0 == lstrcmpA(".", find_data.cFileName) || + 0 == lstrcmpA("..", find_data.cFileName)) + { + continue; + } + } + + if(flags & GLOB_MARK) + { +#if 0 + if(find_data.cFileName[0] >= 'A' && find_data.cFileName[0] <= 'M') +#endif /* 0 */ + (void)lstrcatA(find_data.cFileName, "/"); + } + } + else + { + if(flags & GLOB_ONLYDIR) + { + /* Skip all further actions, and get the next entry */ +#if 0 + if(find_data.cFileName[0] >= 'A' && find_data.cFileName[0] <= 'M') +#endif /* 0 */ + continue; + } + } + + cch = lstrlenA(find_data.cFileName); + if(NULL != file_part) + { + cch += (int)(file_part - effectivePattern); + } + + new_cbAlloc = (size_t)cbCurr + cch + 1; + if(new_cbAlloc > cbAlloc) + { + char *new_buffer; + + new_cbAlloc *= 2; + + new_cbAlloc = (new_cbAlloc + 31) & ~(31); + + new_buffer = (char*)realloc(buffer, new_cbAlloc); + + if(new_buffer == NULL) + { + result = GLOB_NOSPACE; + free(buffer); + buffer = NULL; + break; + } + + buffer = new_buffer; + cbAlloc = new_cbAlloc; + } + + (void)lstrcpynA(buffer + cbCurr, szRelative, 1 + (int)(file_part - effectivePattern)); + (void)lstrcatA(buffer + cbCurr, find_data.cFileName); + cbCurr += cch + 1; + + ++cMatches; + } + while(FindNextFile(hFind, &find_data) && cMatches != maxMatches); + + (void)FindClose(hFind); + + if(result == 0) + { + /* Now expand the buffer, to fit in all the pointers. */ + size_t cbPointers = (1 + cMatches + pglob->gl_offs) * sizeof(char*); + char *new_buffer = (char*)realloc(buffer, cbAlloc + cbPointers); + + if(new_buffer == NULL) + { + result = GLOB_NOSPACE; + free(buffer); + } + else + { + char **pp; + char **begin; + char **end; + char *next_str; + + buffer = new_buffer; + + (void)memmove(new_buffer + cbPointers, new_buffer, cbAlloc); + + /* Handle the offsets. */ + begin = (char**)new_buffer; + end = begin + pglob->gl_offs; + + for(; begin != end; ++begin) + { + *begin = NULL; + } + + /* Sort, or no sort. */ + pp = (char**)new_buffer + pglob->gl_offs; + begin = pp; + end = begin + cMatches; + + if(flags & GLOB_NOSORT) + { + /* The way we need in order to test the removal of dots in the findfile_sequence. */ + *end = NULL; + for(begin = pp, next_str = buffer + cbPointers; begin != end; --end) + { + *(end - 1) = next_str; + + /* Find the next string. */ + next_str += 1 + lstrlenA(next_str); + } + } + else + { + /* The normal way. */ + for(begin = pp, next_str = buffer + cbPointers; begin != end; ++begin) + { + *begin = next_str; + + /* Find the next string. */ + next_str += 1 + lstrlenA(next_str); + } + *begin = NULL; + } + + /* Return results to caller. */ + pglob->gl_pathc = (int)cMatches; + pglob->gl_matchc= (int)cMatches; + pglob->gl_flags = 0; + if(bMagic) + { + pglob->gl_flags |= GLOB_MAGCHAR; + } + pglob->gl_pathv = (char**)new_buffer; + } + } + + if(0 == cMatches) + { + result = GLOB_NOMATCH; + } + } + + if(GLOB_NOMATCH == result) + { + if( (flags & GLOB_TILDE_CHECK) && + effectivePattern == szPattern3) + { + result = GLOB_NOMATCH; + } + else if(bNoMagic || + (flags & GLOB_NOCHECK)) + { + const size_t effPattLen = strlen(effectivePattern); + const size_t cbNeeded = ((2 + pglob->gl_offs) * sizeof(char*)) + (1 + effPattLen); + char **pp = (char**)realloc(buffer, cbNeeded); + + if(NULL == pp) + { + result = GLOB_NOSPACE; + free(buffer); + } + else + { + /* Handle the offsets. */ + char** begin = pp; + char** end = pp + pglob->gl_offs; + char* dest = (char*)(pp + 2 + pglob->gl_offs); + + for(; begin != end; ++begin) + { + *begin = NULL; + } + + /* Synthesise the pattern result. */ +#ifdef UNIXEM_USING_SAFE_STR_FUNCTIONS + pp[0 + pglob->gl_offs] = (strcpy_s(dest, effPattLen + 1, effectivePattern), dest); +#else /* ? UNIXEM_USING_SAFE_STR_FUNCTIONS */ + pp[0 + pglob->gl_offs] = strcpy(dest, effectivePattern); +#endif /* UNIXEM_USING_SAFE_STR_FUNCTIONS */ + pp[1 + pglob->gl_offs] = NULL; + + /* Return results to caller. */ + pglob->gl_pathc = 1; + pglob->gl_matchc= 1; + pglob->gl_flags = 0; + if(bMagic) + { + pglob->gl_flags |= GLOB_MAGCHAR; + } + pglob->gl_pathv = pp; + + result = 0; + } + } + } + else if(0 == result) + { + if((size_t)pglob->gl_matchc == maxMatches) + { + result = GLOB_NOSPACE; + } + } + + return result; +} + +void globfree(glob_t *pglob) +{ + if(pglob != NULL) + { + free(pglob->gl_pathv); + pglob->gl_pathc = 0; + pglob->gl_pathv = NULL; + } +} + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index cc1d38368..b88687768 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -29,6 +29,8 @@ #include "sdl_private.h" #include "window.h" #include "noimpl.h" +#include +#include #include "leak_dumper.h" @@ -214,8 +216,8 @@ void Tokenize(const string& str,vector& tokens,const string& delimiters) void findDirs(const vector &paths, vector &results, bool errorOnNotFound) { results.clear(); - int pathCount = paths.size(); - for(int idx = 0; idx < pathCount; idx++) { + size_t pathCount = paths.size(); + for(unsigned int idx = 0; idx < pathCount; idx++) { string path = paths[idx] + "/*."; vector current_results; findAll(path, current_results, false, errorOnNotFound); @@ -237,8 +239,8 @@ void findDirs(const vector &paths, vector &results, bool errorOn void findAll(const vector &paths, const string &fileFilter, vector &results, bool cutExtension, bool errorOnNotFound) { results.clear(); - int pathCount = paths.size(); - for(int idx = 0; idx < pathCount; idx++) { + size_t pathCount = paths.size(); + for(unsigned int idx = 0; idx < pathCount; idx++) { string path = paths[idx] + "/" + fileFilter; vector current_results; findAll(path, current_results, cutExtension, errorOnNotFound); @@ -332,8 +334,8 @@ bool EndsWith(const string &str, const string& key) //finds all filenames like path and gets their checksum of all files combined int32 getFolderTreeContentsCheckSumRecursively(vector paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) { Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum); - int count = paths.size(); - for(int idx = 0; idx < count; ++idx) { + size_t count = paths.size(); + for(unsigned int idx = 0; idx < count; ++idx) { string path = paths[idx] + pathSearchString; getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum); } @@ -348,93 +350,98 @@ int32 getFolderTreeContentsCheckSumRecursively(vector paths, string path //finds all filenames like path and gets their checksum of all files combined int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) { - Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum); - -/* MV - PORT THIS to win32 - - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); - - std::string mypath = path; - // Stupid win32 is searching for all files without extension when *. is specified as wildcard - if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) { - mypath = mypath.substr(0, mypath.size() - 2); - mypath += "*"; - } - - glob_t globbuf; - - int res = glob(mypath.c_str(), 0, 0, &globbuf); - if(res < 0) { - std::stringstream msg; - msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); - throw runtime_error(msg.str()); - } - - for(size_t i = 0; i < globbuf.gl_pathc; ++i) { - const char* p = globbuf.gl_pathv[i]; - // - //const char* begin = p; - //for( ; *p != 0; ++p) { - // // strip the path component - // if(*p == '/') - // begin = p+1; - //} - - - if(isdir(p) == false) - { - bool addFile = true; - if(filterFileExt != "") - { - addFile = EndsWith(p, filterFileExt); - } - - if(addFile) - { - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); - - checksum.addFile(p); - } - } - } - - globfree(&globbuf); - - // Look recursively for sub-folders - res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf); - if(res < 0) { - std::stringstream msg; - msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); - throw runtime_error(msg.str()); - } - - for(size_t i = 0; i < globbuf.gl_pathc; ++i) { - const char* p = globbuf.gl_pathv[i]; - // - //const char* begin = p; - //for( ; *p != 0; ++p) { - // strip the path component - // if(*p == '/') - // begin = p+1; - //} - - getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum); - } - - globfree(&globbuf); -*/ - - if(recursiveChecksum != NULL) { - *recursiveChecksum = checksum; - } - - return checksum.getSum(); + + Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum()); + + std::string mypath = path; + /** Stupid win32 is searching for all files without extension when *. is + * specified as wildcard + */ + if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) { + mypath = mypath.substr(0, mypath.size() - 2); + mypath += "*"; + } + + glob_t globbuf; + + int res = glob(mypath.c_str(), 0, 0, &globbuf); + if(res < 0) { + std::stringstream msg; + msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); + throw runtime_error(msg.str()); + } + + for(size_t i = 0; i < globbuf.gl_pathc; ++i) { + const char* p = globbuf.gl_pathv[i]; + /* + const char* begin = p; + for( ; *p != 0; ++p) { + // strip the path component + if(*p == '/') + begin = p+1; + } + */ + + //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] examining file [%s]\n",__FILE__,__FUNCTION__,p); + + if(isdir(p) == false) + { + bool addFile = true; + if(filterFileExt != "") + { + addFile = EndsWith(p, filterFileExt); + } + + if(addFile) + { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); + + checksum.addFile(p); + } + } + } + + globfree(&globbuf); + + // Look recursively for sub-folders + res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf); + if(res < 0) { + std::stringstream msg; + msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); + throw runtime_error(msg.str()); + } + + for(size_t i = 0; i < globbuf.gl_pathc; ++i) { + const char* p = globbuf.gl_pathv[i]; + /* + const char* begin = p; + for( ; *p != 0; ++p) { + // strip the path component + if(*p == '/') + begin = p+1; + } + */ + + getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum); + } + + globfree(&globbuf); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum()); + + if(recursiveChecksum != NULL) { + *recursiveChecksum = checksum; + } + + return checksum.getSum(); } vector > getFolderTreeContentsCheckSumListRecursively(vector paths, string pathSearchString, string filterFileExt, vector > *recursiveMap) { vector > checksumFiles = (recursiveMap == NULL ? vector >() : *recursiveMap); - int count = paths.size(); - for(int idx = 0; idx < count; ++idx) { + size_t count = paths.size(); + for(unsigned int idx = 0; idx < count; ++idx) { string path = paths[idx] + pathSearchString; getFolderTreeContentsCheckSumListRecursively(path, filterFileExt, &checksumFiles); } @@ -444,85 +451,88 @@ vector > getFolderTreeContentsCheckSumListRecursively(ve //finds all filenames like path and gets the checksum of each file vector > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector > *recursiveMap) { - vector > checksumFiles = (recursiveMap == NULL ? vector >() : *recursiveMap); - -/* MV - PORT THIS to win32 - - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); - - std::string mypath = path; - // Stupid win32 is searching for all files without extension when *. is specified as wildcard - if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) { - mypath = mypath.substr(0, mypath.size() - 2); - mypath += "*"; - } - - glob_t globbuf; - - int res = glob(mypath.c_str(), 0, 0, &globbuf); - if(res < 0) { - std::stringstream msg; - msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); - throw runtime_error(msg.str()); - } - - for(size_t i = 0; i < globbuf.gl_pathc; ++i) { - const char* p = globbuf.gl_pathv[i]; - // - //const char* begin = p; - //for( ; *p != 0; ++p) { - // strip the path component - // if(*p == '/') - // begin = p+1; - //} - - - if(isdir(p) == false) - { - bool addFile = true; - if(filterFileExt != "") - { - addFile = EndsWith(p, filterFileExt); - } - - if(addFile) - { - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); - - Checksum checksum; - checksum.addFile(p); - - checksumFiles.push_back(std::pair(p,checksum.getSum())); - } - } - } - - globfree(&globbuf); - - // Look recursively for sub-folders - res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf); - if(res < 0) { - std::stringstream msg; - msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); - throw runtime_error(msg.str()); - } - - for(size_t i = 0; i < globbuf.gl_pathc; ++i) { - const char* p = globbuf.gl_pathv[i]; - // - //const char* begin = p; - //for( ; *p != 0; ++p) { - // strip the path component - // if(*p == '/') - // begin = p+1; - //} - - checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles); - } - - globfree(&globbuf); -*/ - return checksumFiles; + vector > checksumFiles = (recursiveMap == NULL ? vector >() : *recursiveMap); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); + + std::string mypath = path; + /** Stupid win32 is searching for all files without extension when *. is + * specified as wildcard + */ + if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) { + mypath = mypath.substr(0, mypath.size() - 2); + mypath += "*"; + } + + glob_t globbuf; + + int res = glob(mypath.c_str(), 0, 0, &globbuf); + if(res < 0) { + std::stringstream msg; + msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); + throw runtime_error(msg.str()); + } + + for(size_t i = 0; i < globbuf.gl_pathc; ++i) { + const char* p = globbuf.gl_pathv[i]; + /* + const char* begin = p; + for( ; *p != 0; ++p) { + // strip the path component + if(*p == '/') + begin = p+1; + } + */ + + if(isdir(p) == false) + { + bool addFile = true; + if(filterFileExt != "") + { + addFile = EndsWith(p, filterFileExt); + } + + if(addFile) + { + //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); + + Checksum checksum; + checksum.addFile(p); + + checksumFiles.push_back(std::pair(p,checksum.getSum())); + } + } + } + + globfree(&globbuf); + + // Look recursively for sub-folders + res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf); + if(res < 0) { + std::stringstream msg; + msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno); + throw runtime_error(msg.str()); + } + + for(size_t i = 0; i < globbuf.gl_pathc; ++i) { + const char* p = globbuf.gl_pathv[i]; + /* + const char* begin = p; + for( ; *p != 0; ++p) { + // strip the path component + if(*p == '/') + begin = p+1; + } + */ + + checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles); + } + + globfree(&globbuf); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); + + return checksumFiles; } string extractDirectoryPathFromFile(string filename) @@ -700,7 +710,7 @@ void getFullscreenVideoModes(list *modeinfos) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SDL_PixelFormat format; - SDL_Rect **modes; + //SDL_Rect **modes; int loops(0); int bpp(0); std::map uniqueResList;