Bug 655039 - Remove WinCE code from libmar; r=rstrong
authorEd Morley <bmo@edmorley.co.uk>
Thu, 05 May 2011 17:14:43 -0400
changeset 69074 48ba96443bca93fa493a571a5b0530fa38271dc9
parent 69073 8056d9a01d44d12144d10ca89af55a667b8bdfc2
child 69075 cd5886d031b5aa4cb84d98082ee607a291fd49b1
push id19852
push userbzbarsky@mozilla.com
push dateSat, 07 May 2011 02:06:27 +0000
treeherdermozilla-central@62941612320d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs655039
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 655039 - Remove WinCE code from libmar; r=rstrong
modules/libmar/src/mar.h
modules/libmar/src/mar_create.c
modules/libmar/src/mar_extract.c
--- a/modules/libmar/src/mar.h
+++ b/modules/libmar/src/mar.h
@@ -35,23 +35,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MAR_H__
 #define MAR_H__
 
 /* We use NSPR here just to import the definition of PRUint32 */
-#ifndef WINCE
 #include "prtypes.h"
-#else
-typedef int PRInt32;
-typedef unsigned int PRUint32;
-typedef wchar_t PRUnichar;
-#endif
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /**
  * The MAR item data structure.
  */
--- a/modules/libmar/src/mar_create.c
+++ b/modules/libmar/src/mar_create.c
@@ -123,24 +123,17 @@ static int mar_concat_file(FILE *fp, con
 
   fclose(in);
   return rv;
 }
 
 int mar_create(const char *dest, int num_files, char **files) {
   struct MarItemStack stack;
   PRUint32 offset_to_index = 0, size_of_index;
-#ifdef WINCE
-  WIN32_FIND_DATAW file_data;
-  PRUnichar wide_path[MAX_PATH];
-  size_t size;
-  PRInt32 flags;
-#else
   struct stat st;
-#endif
   FILE *fp;
   int i, rv = -1;
 
   memset(&stack, 0, sizeof(stack));
 
   fp = fopen(dest, "wb");
   if (!fp) {
     fprintf(stderr, "ERROR: could not create target file: %s\n", dest);
@@ -150,37 +143,22 @@ int mar_create(const char *dest, int num
   if (fwrite(MAR_ID, MAR_ID_SIZE, 1, fp) != 1)
     goto failure;
   if (fwrite(&offset_to_index, sizeof(PRUint32), 1, fp) != 1)
     goto failure;
 
   stack.last_offset = MAR_ID_SIZE + sizeof(PRUint32);
 
   for (i = 0; i < num_files; ++i) {
-#ifdef WINCE
-    HANDLE handle;
-    MultiByteToWideChar(CP_ACP, 0, files[i], -1, wide_path, MAX_PATH);
-    handle = FindFirstFile(wide_path, &file_data);
-    if (handle == INVALID_HANDLE_VALUE) {
-#else
     if (stat(files[i], &st)) {
-#endif
       fprintf(stderr, "ERROR: file not found: %s\n", files[i]);
       goto failure;
     }
-#ifdef WINCE
-    flags = (file_data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ?
-      0444 : 0666;
-    size = (file_data.nFileSizeHigh * (MAXDWORD + 1)) + file_data.nFileSizeLow;
-    FindClose(handle);
-    if (mar_push(&stack, size, flags, files[i]))
-#else
 
     if (mar_push(&stack, st.st_size, st.st_mode & 0777, files[i]))
-#endif
       goto failure;
 
     /* concatenate input file to archive */
     if (mar_concat_file(fp, files[i]))
       goto failure;
   }
 
   /* write out the index (prefixed with length of index) */
@@ -198,18 +176,11 @@ int mar_create(const char *dest, int num
     goto failure;
 
   rv = 0;
 failure: 
   if (stack.head)
     free(stack.head);
   fclose(fp);
   if (rv)
-#ifdef WINCE
-    {
-      MultiByteToWideChar(CP_ACP, 0, dest, -1, wide_path, MAX_PATH);
-      DeleteFileW(wide_path);
-    }
-#else
     remove(dest);
-#endif
   return rv;
 }
--- a/modules/libmar/src/mar_extract.c
+++ b/modules/libmar/src/mar_extract.c
@@ -43,67 +43,53 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "mar.h"
 #include "mar_private.h"
 
 #ifdef XP_WIN
 #include <io.h>
 #include <direct.h>
-#ifdef WINCE
-#include <windows.h>
-#endif
 #endif
 
 /* Ensure that the directory containing this file exists */
 static int mar_ensure_parent_dir(const char *path)
 {
   char *slash = strrchr(path, '/');
-#ifdef WINCE
-  wchar_t wide_path[MAX_PATH];
-#endif
   if (slash)
   {
     *slash = '\0';
     mar_ensure_parent_dir(path);
 #ifdef XP_WIN
-#ifdef WINCE
-    MultiByteToWideChar(CP_ACP, 0, path, -1, wide_path, MAX_PATH);
-    CreateDirectory(wide_path, NULL);
-#else
     _mkdir(path);
-#endif
 #else
     mkdir(path, 0755);
 #endif
     *slash = '/';
   }
   return 0;
 }
 
 static int mar_test_callback(MarFile *mar, const MarItem *item, void *unused) {
   FILE *fp;
   char buf[BLOCKSIZE];
   int fd, len, offset = 0;
 
   if (mar_ensure_parent_dir(item->name))
     return -1;
-#ifdef WINCE 
-  fp = fopen(item->name, "bw");
-#else
+
 #ifdef XP_WIN
   fd = _open(item->name, _O_BINARY|_O_CREAT|_O_TRUNC|_O_WRONLY, item->flags);
 #else
   fd = creat(item->name, item->flags);
 #endif
   if (fd == -1)
     return -1;
 
   fp = fdopen(fd, "wb");
-#endif
   if (!fp)
     return -1;
 
   while ((len = mar_read(mar, item, offset, buf, sizeof(buf))) > 0) {
     if (fwrite(buf, len, 1, fp) != 1)
       break;
     offset += len;
   }