platform/pocketpc.c
changeset 792 4c278733e281
parent 763 efadd9cdb6a4
child 793 c75c9498c001
--- a/platform/pocketpc.c	Thu Mar 08 22:22:24 2007 +0000
+++ b/platform/pocketpc.c	Thu Mar 08 22:37:51 2007 +0000
@@ -69,26 +69,21 @@
 {
     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 */
 
 
@@ -127,20 +122,20 @@
 
     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)
@@ -156,13 +151,12 @@
 
     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();
@@ -229,9 +223,9 @@
     
     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 */
@@ -251,9 +245,9 @@
 
     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 */
@@ -372,20 +366,16 @@
 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 */
 
 
@@ -402,7 +392,7 @@
 
     if(fileHandle==INVALID_HANDLE_VALUE)
     {
-    return NULL;
+        return NULL;
     }
 
     BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
@@ -410,8 +400,8 @@
     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;