Bug 655039 - Remove WinCE code from libmar; r=rstrong

This commit is contained in:
Ed Morley 2011-05-05 17:14:43 -04:00
parent 8f81bdd6cf
commit 370527db8c
3 changed files with 1 additions and 50 deletions

View File

@ -40,13 +40,7 @@
#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" {

View File

@ -128,14 +128,7 @@ static int mar_concat_file(FILE *fp, const char *path) {
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;
@ -155,27 +148,12 @@ int mar_create(const char *dest, int num_files, char **files) {
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 */
@ -203,13 +181,6 @@ failure:
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;
}

View File

@ -48,29 +48,18 @@
#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
@ -86,9 +75,7 @@ static int mar_test_callback(MarFile *mar, const MarItem *item, void *unused) {
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
@ -98,7 +85,6 @@ static int mar_test_callback(MarFile *mar, const MarItem *item, void *unused) {
return -1;
fp = fdopen(fd, "wb");
#endif
if (!fp)
return -1;