mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-30 21:30:58 +00:00
- Fixed zipdir for Windows.
SVN r1090 (trunk)
This commit is contained in:
parent
a65f5c67a3
commit
2f7b7673f8
2 changed files with 83 additions and 84 deletions
|
@ -1,5 +1,5 @@
|
||||||
July 23, 2008 (Changes by Graf Zahl)
|
July 23, 2008 (Changes by Graf Zahl)
|
||||||
- Fixed: Thew sounds of Strife's intro need CHAN_UI.
|
- Fixed: The sounds of Strife's intro need CHAN_UI.
|
||||||
- Changed all instances of playing the chat sounds to use CHAN_UI.
|
- Changed all instances of playing the chat sounds to use CHAN_UI.
|
||||||
|
|
||||||
July 21, 2008
|
July 21, 2008
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
// HEADER FILES ------------------------------------------------------------
|
// HEADER FILES ------------------------------------------------------------
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#define stat _stat
|
#define stat _stat
|
||||||
#else
|
#else
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <fts.h>
|
#include <fts.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -83,11 +83,11 @@ void print_usage(const char *cmdname);
|
||||||
dir_tree_t *alloc_dir_tree(const char *dir);
|
dir_tree_t *alloc_dir_tree(const char *dir);
|
||||||
file_entry_t *alloc_file_entry(const char *prefix, const char *path, time_t last_written);
|
file_entry_t *alloc_file_entry(const char *prefix, const char *path, time_t last_written);
|
||||||
void free_dir_tree(dir_tree_t *tree);
|
void free_dir_tree(dir_tree_t *tree);
|
||||||
void free_dir_trees(dir_tree_t *tree);
|
void free_dir_trees(dir_tree_t *tree);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void recurse_dir(dir_tree_t *tree, const char *dirpath);
|
void recurse_dir(dir_tree_t *tree, const char *dirpath);
|
||||||
dir_tree_t *add_dir(const char *dirpath);
|
dir_tree_t *add_dir(const char *dirpath);
|
||||||
#endif
|
#endif
|
||||||
dir_tree_t *add_dirs(char **argv);
|
dir_tree_t *add_dirs(char **argv);
|
||||||
int count_files(dir_tree_t *trees);
|
int count_files(dir_tree_t *trees);
|
||||||
int __cdecl sort_cmp(const void *a, const void *b);
|
int __cdecl sort_cmp(const void *a, const void *b);
|
||||||
|
@ -162,17 +162,17 @@ dir_tree_t *alloc_dir_tree(const char *dir)
|
||||||
|
|
||||||
file_entry_t *alloc_file_entry(const char *prefix, const char *path, time_t last_written)
|
file_entry_t *alloc_file_entry(const char *prefix, const char *path, time_t last_written)
|
||||||
{
|
{
|
||||||
file_entry_t *entry;
|
file_entry_t *entry;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
entry = malloc(sizeof(file_entry_t) + strlen(prefix) + strlen(path) + 1);
|
entry = malloc(sizeof(file_entry_t) + strlen(prefix) + strlen(path) + 1);
|
||||||
if (entry != NULL)
|
if (entry != NULL)
|
||||||
{
|
{
|
||||||
strcpy(entry->path, prefix);
|
strcpy(entry->path, prefix);
|
||||||
strcat(entry->path, path);
|
strcat(entry->path, path);
|
||||||
for (p = entry->path; *p != '\0'; ++p)
|
for (p = entry->path; *p != '\0'; ++p)
|
||||||
{
|
{
|
||||||
*p = tolower(*p);
|
*p = tolower(*p);
|
||||||
}
|
}
|
||||||
entry->next = NULL;
|
entry->next = NULL;
|
||||||
entry->time_write = last_written;
|
entry->time_write = last_written;
|
||||||
|
@ -217,8 +217,8 @@ void free_dir_trees(dir_tree_t *tree)
|
||||||
free_dir_tree(tree);
|
free_dir_tree(tree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -227,8 +227,8 @@ void free_dir_trees(dir_tree_t *tree)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void recurse_dir(dir_tree_t *tree, const char *dirpath)
|
void recurse_dir(dir_tree_t *tree, const char *dirpath)
|
||||||
{
|
{
|
||||||
struct _finddata_t fileinfo;
|
struct _finddata_t fileinfo;
|
||||||
intptr_t handle;
|
intptr_t handle;
|
||||||
char *dirmatch;
|
char *dirmatch;
|
||||||
|
|
||||||
|
@ -239,13 +239,13 @@ void recurse_dir(dir_tree_t *tree, const char *dirpath)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy(dirmatch, dirpath);
|
strcpy(dirmatch, dirpath);
|
||||||
strcat(dirmatch, "*");
|
strcat(dirmatch, "*");
|
||||||
if ((handle = _findfirst(dirmatch, &fileinfo)) == -1)
|
if ((handle = _findfirst(dirmatch, &fileinfo)) == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not scan '%s': %s\n", dirpath, strerror(errno));
|
fprintf(stderr, "Could not scan '%s': %s\n", dirpath, strerror(errno));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (fileinfo.attrib & _A_HIDDEN)
|
if (fileinfo.attrib & _A_HIDDEN)
|
||||||
|
@ -285,7 +285,7 @@ void recurse_dir(dir_tree_t *tree, const char *dirpath)
|
||||||
tree->files = entry;
|
tree->files = entry;
|
||||||
}
|
}
|
||||||
} while (_findnext(handle, &fileinfo) == 0);
|
} while (_findnext(handle, &fileinfo) == 0);
|
||||||
_findclose(handle);
|
_findclose(handle);
|
||||||
}
|
}
|
||||||
free(dirmatch);
|
free(dirmatch);
|
||||||
}
|
}
|
||||||
|
@ -306,20 +306,21 @@ dir_tree_t *add_dir(const char *dirpath)
|
||||||
}
|
}
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// add_dirs
|
// add_dirs
|
||||||
// Windows version
|
// Windows version
|
||||||
//
|
//
|
||||||
// Given NULL-terminated array of directory paths, create trees for them.
|
// Given NULL-terminated array of directory paths, create trees for them.
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
dir_tree_t *add_dirs(char **argv)
|
dir_tree_t *add_dirs(char **argv)
|
||||||
{
|
{
|
||||||
dir_tree_t *tree, *trees = NULL;
|
dir_tree_t *tree, *trees = NULL;
|
||||||
|
char *s;
|
||||||
|
|
||||||
while (*argv != NULL)
|
while (*argv != NULL)
|
||||||
{
|
{
|
||||||
for (s = *argv; *s != '\0'; ++s)
|
for (s = *argv; *s != '\0'; ++s)
|
||||||
|
@ -333,61 +334,61 @@ dir_tree_t *add_dirs(char **argv)
|
||||||
tree->next = trees;
|
tree->next = trees;
|
||||||
trees = tree;
|
trees = tree;
|
||||||
if (no_mem)
|
if (no_mem)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return trees;
|
return trees;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// add_dirs
|
// add_dirs
|
||||||
// 4.4BSD version
|
// 4.4BSD version
|
||||||
//
|
//
|
||||||
// Given NULL-terminated array of directory paths, create trees for them.
|
// Given NULL-terminated array of directory paths, create trees for them.
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
dir_tree_t *add_dirs(char **argv)
|
dir_tree_t *add_dirs(char **argv)
|
||||||
{
|
{
|
||||||
FTS *fts;
|
FTS *fts;
|
||||||
FTSENT *ent;
|
FTSENT *ent;
|
||||||
dir_tree_t *tree, *trees = NULL;
|
dir_tree_t *tree, *trees = NULL;
|
||||||
file_entry_t *file;
|
file_entry_t *file;
|
||||||
|
|
||||||
fts = fts_open(argv, FTS_LOGICAL, NULL);
|
fts = fts_open(argv, FTS_LOGICAL, NULL);
|
||||||
if (fts == NULL)
|
if (fts == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to start directory traversal: %s\n", strerror(errno));
|
fprintf(stderr, "Failed to start directory traversal: %s\n", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while ((ent = fts_read(fts)) != NULL)
|
while ((ent = fts_read(fts)) != NULL)
|
||||||
{
|
{
|
||||||
if (ent->fts_info == FTS_D && ent->fts_name[0] == '.')
|
if (ent->fts_info == FTS_D && ent->fts_name[0] == '.')
|
||||||
{
|
{
|
||||||
// Skip hidden directories. (Prevents SVN bookkeeping
|
// Skip hidden directories. (Prevents SVN bookkeeping
|
||||||
// info from being included.)
|
// info from being included.)
|
||||||
fts_set(fts, ent, FTS_SKIP);
|
fts_set(fts, ent, FTS_SKIP);
|
||||||
}
|
}
|
||||||
if (ent->fts_info == FTS_D && ent->fts_level == 0)
|
if (ent->fts_info == FTS_D && ent->fts_level == 0)
|
||||||
{
|
{
|
||||||
tree = alloc_dir_tree(ent->fts_path);
|
tree = alloc_dir_tree(ent->fts_path);
|
||||||
if (tree == NULL)
|
if (tree == NULL)
|
||||||
{
|
{
|
||||||
no_mem = 1;
|
no_mem = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tree->next = trees;
|
tree->next = trees;
|
||||||
trees = tree;
|
trees = tree;
|
||||||
}
|
}
|
||||||
if (ent->fts_info != FTS_F)
|
if (ent->fts_info != FTS_F)
|
||||||
{
|
{
|
||||||
// We're only interested in remembering files.
|
// We're only interested in remembering files.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
file = alloc_file_entry("", ent->fts_path, ent->fts_statp->st_mtime);
|
file = alloc_file_entry("", ent->fts_path, ent->fts_statp->st_mtime);
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
|
@ -396,10 +397,10 @@ dir_tree_t *add_dirs(char **argv)
|
||||||
}
|
}
|
||||||
file->next = tree->files;
|
file->next = tree->files;
|
||||||
tree->files = file;
|
tree->files = file;
|
||||||
}
|
}
|
||||||
fts_close(fts);
|
fts_close(fts);
|
||||||
return trees;
|
return trees;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -608,12 +609,10 @@ int append_to_zip(zipFile zipfile, const file_sorted_t *file)
|
||||||
|
|
||||||
int __cdecl main (int argc, char **argv)
|
int __cdecl main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
dir_tree_t *tree, *trees;
|
dir_tree_t *tree, *trees;
|
||||||
file_entry_t *file;
|
file_entry_t *file;
|
||||||
struct stat zipstat;
|
struct stat zipstat;
|
||||||
int needwrite;
|
int needwrite;
|
||||||
char *s;
|
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue