Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ryanized the formatting in pocketpc.c
  • Loading branch information
icculus committed Mar 8, 2007
1 parent f6790ee commit a41e32d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -3,6 +3,7 @@
*/

03082007 - Fixed a comment in physfs.h. Renamed win32.c to windows.c.
Cleaned up whitespace/formatting in pocketpc.c
11052006 - More 7zip archiver work (thanks, Dennis!). Initial Unicode work.
Minor BeOS realpath tweak.
09272006 - Reworked 7zip archiver (thanks, Dennis!).
Expand Down
88 changes: 39 additions & 49 deletions platform/pocketpc.c
Expand Up @@ -69,26 +69,21 @@ static char *UnicodeToAsc(const wchar_t *w_str)
{
char *str = NULL;

if (w_str != NULL)
if (w_str == NULL)
return NULL;
else
{
int len = wcslen(w_str) + 1;
str = (char *) allocator.Malloc(len);

if (WideCharToMultiByte(CP_ACP,0,w_str,-1,str,len,NULL,NULL) == 0)
{ /*Conversion failed */
if (WideCharToMultiByte(CP_ACP,0,w_str,-1,str,len,NULL,NULL) != 0)
return(str);
else /* Conversion failed */
{
allocator.Free(str);
return(NULL);
} /* if */
else
{ /* Conversion successful */
return(str);
} /* else */
} /* if */

else
{ /* Given NULL string */
return NULL;
}
} /* else */
} /* UnicodeToAsc */


Expand Down Expand Up @@ -127,20 +122,20 @@ static char *getExePath()

retval[0] = _T('\0');
buflen = GetModuleFileName(NULL, retval, MAX_PATH + 1);
if (buflen <= 0) {
if (buflen <= 0)
__PHYSFS_setError(win32strerror());
} else {
retval[buflen] = '\0'; /* does API always null-terminate this? */
ptr = retval+buflen;
while( ptr != retval )
else
{
if( *ptr != _T('\\') ) {
*ptr-- = _T('\0');
} else {
break;
}
}
success = 1;
retval[buflen] = '\0'; /* does API always null-terminate this? */
ptr = retval+buflen;
while( ptr != retval )
{
if( *ptr != _T('\\') )
*ptr-- = _T('\0');
else
break;
} /* while */
success = 1;
} /* else */

if (!success)
Expand All @@ -156,13 +151,12 @@ static char *getExePath()

charretval = UnicodeToAsc(retval);
allocator.Free(retval);
if(charretval == NULL) {
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
}

BAIL_IF_MACRO((!charretval) && (!retval), ERR_OUT_OF_MEMORY, NULL);

return(charretval); /* w00t. */
} /* getExePath */


int __PHYSFS_platformInit(void)
{
userDir = getExePath();
Expand Down Expand Up @@ -229,9 +223,9 @@ int __PHYSFS_platformExists(const char *fname)

if(w_fname!=NULL)
{
retval=(GetFileAttributes(w_fname) != INVALID_FILE_ATTRIBUTES);
allocator.Free(w_fname);
}
retval=(GetFileAttributes(w_fname) != INVALID_FILE_ATTRIBUTES);
allocator.Free(w_fname);
} /* if */

return(retval);
} /* __PHYSFS_platformExists */
Expand All @@ -251,9 +245,9 @@ int __PHYSFS_platformIsDirectory(const char *fname)

if(w_fname!=NULL)
{
retval=((GetFileAttributes(w_fname) & FILE_ATTRIBUTE_DIRECTORY) != 0);
allocator.Free(w_fname);
}
retval=((GetFileAttributes(w_fname) & FILE_ATTRIBUTE_DIRECTORY) != 0);
allocator.Free(w_fname);
} /* if */

return(retval);
} /* __PHYSFS_platformIsDirectory */
Expand Down Expand Up @@ -372,20 +366,16 @@ char *__PHYSFS_platformRealPath(const char *path)
int __PHYSFS_platformMkDir(const char *path)
{
wchar_t *w_path = AscToUnicode(path);
if(w_path!=NULL)
{
DWORD rc = CreateDirectory(w_path, NULL);
allocator.Free(w_path);
if(rc==0)
{
if(w_path == NULL)
return(0);
}
return(1);
}
else
{
return(0);
}
DWORD rc = CreateDirectory(w_path, NULL);
allocator.Free(w_path);
if(rc==0)
return(0);
return(1);
} /* else */
} /* __PHYSFS_platformMkDir */


Expand All @@ -402,16 +392,16 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)

if(fileHandle==INVALID_HANDLE_VALUE)
{
return NULL;
return NULL;
}

BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);

retval = (winCEfile *) allocator.Malloc(sizeof (winCEfile));
if (retval == NULL)
{
CloseHandle(fileHandle);
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
CloseHandle(fileHandle);
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
} /* if */

retval->readonly = rdonly;
Expand Down

0 comments on commit a41e32d

Please sign in to comment.