mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-4351 Fix decmn so that an archive can be taken apart and put back together without special makefile code.
X-SVN-Rev: 17388
This commit is contained in:
parent
6fbe41a6ca
commit
9d88c78dfc
3 changed files with 55 additions and 4 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "unicode/udata.h"
|
||||
#include "uoptions.h"
|
||||
#include "cstring.h"
|
||||
#include "toolutil.h"
|
||||
|
||||
static uint8_t buffer[100000], buffer2[128*1024];
|
||||
|
||||
|
@ -55,7 +56,8 @@ static int
|
|||
copyFile(FILE *in, int32_t offset, int32_t size, const char *dir, const char *name) {
|
||||
FILE *out;
|
||||
int32_t length;
|
||||
char path[512], *p;
|
||||
char path[512], *p, *endDir;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
if(0!=fseek(in, offset, SEEK_SET)) {
|
||||
fprintf(stderr, "%s: cannot seek to position %ld for file \"%s\"\n", pname,
|
||||
|
@ -63,6 +65,32 @@ copyFile(FILE *in, int32_t offset, int32_t size, const char *dir, const char *na
|
|||
return 4;
|
||||
}
|
||||
|
||||
/* Make sure that subdirectories are created first */
|
||||
uprv_strcpy(path, dir);
|
||||
p = path + strlen(path);
|
||||
if (p[-1] != U_FILE_SEP_CHAR) {
|
||||
*p++ = U_FILE_SEP_CHAR;
|
||||
}
|
||||
uprv_strcpy(p, name);
|
||||
endDir = uprv_strrchr(p, U_TREE_ENTRY_SEP_CHAR);
|
||||
if (endDir != NULL) {
|
||||
/* Create the parent directories before creating the current directory. */
|
||||
for (;;) {
|
||||
p = uprv_strchr(p, U_TREE_ENTRY_SEP_CHAR);
|
||||
if (p == NULL) {
|
||||
break;
|
||||
}
|
||||
*p = 0;
|
||||
uprv_mkdir(path, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
fprintf(stderr, "%s: unable to create directory \"%s\"\n", pname, path);
|
||||
return 5;
|
||||
}
|
||||
*(p++) = U_FILE_SEP_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the path with the real name now */
|
||||
uprv_strcpy(path, dir);
|
||||
p = path + strlen(path);
|
||||
if (p[-1] != U_FILE_SEP_CHAR) {
|
||||
|
@ -122,9 +150,9 @@ main(int argc, char *argv[]) {
|
|||
U_MAIN_INIT_ARGS(argc, argv);
|
||||
|
||||
pname = uprv_strchr(*argv, U_FILE_SEP_CHAR);
|
||||
#ifdef U_WINDOWS
|
||||
#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR)
|
||||
if (!pname) {
|
||||
pname = uprv_strchr(*argv, '/');
|
||||
pname = uprv_strchr(*argv, U_FILE_ALT_SEP_CHAR);
|
||||
}
|
||||
#endif
|
||||
if (pname) {
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
# define NOIME
|
||||
# define NOMCX
|
||||
# include <windows.h>
|
||||
# include <direct.h>
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
|
@ -76,6 +78,19 @@ findBasename(const char *filename) {
|
|||
}
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uprv_mkdir(const char *pathname, UErrorCode *status) {
|
||||
int retVal = 0;
|
||||
#if defined(U_WINDOWS)
|
||||
retVal = _mkdir(pathname);
|
||||
#else
|
||||
retVal = mkdir(pathname, S_IRWXU | (S_IROTH | S_IXOTH) | (S_IROTH | S_IXOTH));
|
||||
#endif
|
||||
if (retVal && errno != EEXIST) {
|
||||
*status = U_FILE_ACCESS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* tool memory helper ------------------------------------------------------- */
|
||||
|
||||
struct UToolMemory {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2003, International Business Machines
|
||||
* Copyright (C) 1999-2005, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
|
@ -49,6 +49,14 @@ getLongPathname(const char *pathname);
|
|||
U_CAPI const char * U_EXPORT2
|
||||
findBasename(const char *filename);
|
||||
|
||||
/*
|
||||
* Creates a diretory with pathname.
|
||||
*
|
||||
* @param status Set to an error code when mkdir failed.
|
||||
*/
|
||||
U_CAPI void U_EXPORT2
|
||||
uprv_mkdir(const char *pathname, UErrorCode *status);
|
||||
|
||||
/*
|
||||
* UToolMemory is used for generic, custom memory management.
|
||||
* It is allocated with enough space for count*size bytes starting
|
||||
|
|
Loading…
Add table
Reference in a new issue