Ryanized the formatting in pocketpc.c

This commit is contained in:
Ryan C. Gordon 2007-03-08 22:37:51 +00:00
parent f6790ee34e
commit a41e32d112
2 changed files with 40 additions and 49 deletions

View File

@ -3,6 +3,7 @@
*/ */
03082007 - Fixed a comment in physfs.h. Renamed win32.c to windows.c. 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. 11052006 - More 7zip archiver work (thanks, Dennis!). Initial Unicode work.
Minor BeOS realpath tweak. Minor BeOS realpath tweak.
09272006 - Reworked 7zip archiver (thanks, Dennis!). 09272006 - Reworked 7zip archiver (thanks, Dennis!).

View File

@ -69,26 +69,21 @@ static char *UnicodeToAsc(const wchar_t *w_str)
{ {
char *str = NULL; char *str = NULL;
if (w_str != NULL) if (w_str == NULL)
return NULL;
else
{ {
int len = wcslen(w_str) + 1; int len = wcslen(w_str) + 1;
str = (char *) allocator.Malloc(len); str = (char *) allocator.Malloc(len);
if (WideCharToMultiByte(CP_ACP,0,w_str,-1,str,len,NULL,NULL) == 0) if (WideCharToMultiByte(CP_ACP,0,w_str,-1,str,len,NULL,NULL) != 0)
{ /*Conversion failed */ return(str);
else /* Conversion failed */
{
allocator.Free(str); allocator.Free(str);
return(NULL); return(NULL);
} /* if */
else
{ /* Conversion successful */
return(str);
} /* else */ } /* else */
} /* if */ } /* else */
else
{ /* Given NULL string */
return NULL;
}
} /* UnicodeToAsc */ } /* UnicodeToAsc */
@ -127,20 +122,20 @@ static char *getExePath()
retval[0] = _T('\0'); retval[0] = _T('\0');
buflen = GetModuleFileName(NULL, retval, MAX_PATH + 1); buflen = GetModuleFileName(NULL, retval, MAX_PATH + 1);
if (buflen <= 0) { if (buflen <= 0)
__PHYSFS_setError(win32strerror()); __PHYSFS_setError(win32strerror());
} else { else
retval[buflen] = '\0'; /* does API always null-terminate this? */
ptr = retval+buflen;
while( ptr != retval )
{ {
if( *ptr != _T('\\') ) { retval[buflen] = '\0'; /* does API always null-terminate this? */
*ptr-- = _T('\0'); ptr = retval+buflen;
} else { while( ptr != retval )
break; {
} if( *ptr != _T('\\') )
} *ptr-- = _T('\0');
success = 1; else
break;
} /* while */
success = 1;
} /* else */ } /* else */
if (!success) if (!success)
@ -156,13 +151,12 @@ static char *getExePath()
charretval = UnicodeToAsc(retval); charretval = UnicodeToAsc(retval);
allocator.Free(retval); allocator.Free(retval);
if(charretval == NULL) { BAIL_IF_MACRO((!charretval) && (!retval), ERR_OUT_OF_MEMORY, NULL);
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
}
return(charretval); /* w00t. */ return(charretval); /* w00t. */
} /* getExePath */ } /* getExePath */
int __PHYSFS_platformInit(void) int __PHYSFS_platformInit(void)
{ {
userDir = getExePath(); userDir = getExePath();
@ -229,9 +223,9 @@ int __PHYSFS_platformExists(const char *fname)
if(w_fname!=NULL) if(w_fname!=NULL)
{ {
retval=(GetFileAttributes(w_fname) != INVALID_FILE_ATTRIBUTES); retval=(GetFileAttributes(w_fname) != INVALID_FILE_ATTRIBUTES);
allocator.Free(w_fname); allocator.Free(w_fname);
} } /* if */
return(retval); return(retval);
} /* __PHYSFS_platformExists */ } /* __PHYSFS_platformExists */
@ -251,9 +245,9 @@ int __PHYSFS_platformIsDirectory(const char *fname)
if(w_fname!=NULL) if(w_fname!=NULL)
{ {
retval=((GetFileAttributes(w_fname) & FILE_ATTRIBUTE_DIRECTORY) != 0); retval=((GetFileAttributes(w_fname) & FILE_ATTRIBUTE_DIRECTORY) != 0);
allocator.Free(w_fname); allocator.Free(w_fname);
} } /* if */
return(retval); return(retval);
} /* __PHYSFS_platformIsDirectory */ } /* __PHYSFS_platformIsDirectory */
@ -372,20 +366,16 @@ char *__PHYSFS_platformRealPath(const char *path)
int __PHYSFS_platformMkDir(const char *path) int __PHYSFS_platformMkDir(const char *path)
{ {
wchar_t *w_path = AscToUnicode(path); wchar_t *w_path = AscToUnicode(path);
if(w_path!=NULL) if(w_path == NULL)
{
DWORD rc = CreateDirectory(w_path, NULL);
allocator.Free(w_path);
if(rc==0)
{
return(0); return(0);
}
return(1);
}
else else
{ {
return(0); DWORD rc = CreateDirectory(w_path, NULL);
} allocator.Free(w_path);
if(rc==0)
return(0);
return(1);
} /* else */
} /* __PHYSFS_platformMkDir */ } /* __PHYSFS_platformMkDir */
@ -402,7 +392,7 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
if(fileHandle==INVALID_HANDLE_VALUE) if(fileHandle==INVALID_HANDLE_VALUE)
{ {
return NULL; return NULL;
} }
BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL); BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
@ -410,8 +400,8 @@ static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
retval = (winCEfile *) allocator.Malloc(sizeof (winCEfile)); retval = (winCEfile *) allocator.Malloc(sizeof (winCEfile));
if (retval == NULL) if (retval == NULL)
{ {
CloseHandle(fileHandle); CloseHandle(fileHandle);
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
} /* if */ } /* if */
retval->readonly = rdonly; retval->readonly = rdonly;