mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 00:31:54 +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)
|
||||
- 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.
|
||||
|
||||
July 21, 2008
|
||||
|
|
|
@ -30,13 +30,13 @@
|
|||
// HEADER FILES ------------------------------------------------------------
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#define stat _stat
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include <fts.h>
|
||||
#include <io.h>
|
||||
#define stat _stat
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include <fts.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -83,11 +83,11 @@ void print_usage(const char *cmdname);
|
|||
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);
|
||||
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
|
||||
void recurse_dir(dir_tree_t *tree, const char *dirpath);
|
||||
dir_tree_t *add_dir(const char *dirpath);
|
||||
#endif
|
||||
dir_tree_t *add_dir(const char *dirpath);
|
||||
#endif
|
||||
dir_tree_t *add_dirs(char **argv);
|
||||
int count_files(dir_tree_t *trees);
|
||||
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 *entry;
|
||||
file_entry_t *entry;
|
||||
char *p;
|
||||
|
||||
entry = malloc(sizeof(file_entry_t) + strlen(prefix) + strlen(path) + 1);
|
||||
if (entry != NULL)
|
||||
{
|
||||
strcpy(entry->path, prefix);
|
||||
strcat(entry->path, path);
|
||||
for (p = entry->path; *p != '\0'; ++p)
|
||||
{
|
||||
*p = tolower(*p);
|
||||
strcat(entry->path, path);
|
||||
for (p = entry->path; *p != '\0'; ++p)
|
||||
{
|
||||
*p = tolower(*p);
|
||||
}
|
||||
entry->next = NULL;
|
||||
entry->time_write = last_written;
|
||||
|
@ -217,8 +217,8 @@ void free_dir_trees(dir_tree_t *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)
|
||||
{
|
||||
struct _finddata_t fileinfo;
|
||||
{
|
||||
struct _finddata_t fileinfo;
|
||||
intptr_t handle;
|
||||
char *dirmatch;
|
||||
|
||||
|
@ -239,13 +239,13 @@ void recurse_dir(dir_tree_t *tree, const char *dirpath)
|
|||
return;
|
||||
}
|
||||
strcpy(dirmatch, dirpath);
|
||||
strcat(dirmatch, "*");
|
||||
if ((handle = _findfirst(dirmatch, &fileinfo)) == -1)
|
||||
strcat(dirmatch, "*");
|
||||
if ((handle = _findfirst(dirmatch, &fileinfo)) == -1)
|
||||
{
|
||||
fprintf(stderr, "Could not scan '%s': %s\n", dirpath, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
do
|
||||
{
|
||||
if (fileinfo.attrib & _A_HIDDEN)
|
||||
|
@ -285,7 +285,7 @@ void recurse_dir(dir_tree_t *tree, const char *dirpath)
|
|||
tree->files = entry;
|
||||
}
|
||||
} while (_findnext(handle, &fileinfo) == 0);
|
||||
_findclose(handle);
|
||||
_findclose(handle);
|
||||
}
|
||||
free(dirmatch);
|
||||
}
|
||||
|
@ -306,20 +306,21 @@ dir_tree_t *add_dir(const char *dirpath)
|
|||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// add_dirs
|
||||
// add_dirs
|
||||
// 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;
|
||||
|
||||
char *s;
|
||||
|
||||
while (*argv != NULL)
|
||||
{
|
||||
for (s = *argv; *s != '\0'; ++s)
|
||||
|
@ -333,61 +334,61 @@ dir_tree_t *add_dirs(char **argv)
|
|||
tree->next = trees;
|
||||
trees = tree;
|
||||
if (no_mem)
|
||||
{
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// add_dirs
|
||||
// add_dirs
|
||||
// 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)
|
||||
{
|
||||
FTS *fts;
|
||||
FTSENT *ent;
|
||||
dir_tree_t *tree, *trees = NULL;
|
||||
file_entry_t *file;
|
||||
|
||||
fts = fts_open(argv, FTS_LOGICAL, NULL);
|
||||
if (fts == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to start directory traversal: %s\n", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
while ((ent = fts_read(fts)) != NULL)
|
||||
{
|
||||
if (ent->fts_info == FTS_D && ent->fts_name[0] == '.')
|
||||
{
|
||||
|
||||
dir_tree_t *add_dirs(char **argv)
|
||||
{
|
||||
FTS *fts;
|
||||
FTSENT *ent;
|
||||
dir_tree_t *tree, *trees = NULL;
|
||||
file_entry_t *file;
|
||||
|
||||
fts = fts_open(argv, FTS_LOGICAL, NULL);
|
||||
if (fts == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to start directory traversal: %s\n", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
while ((ent = fts_read(fts)) != NULL)
|
||||
{
|
||||
if (ent->fts_info == FTS_D && ent->fts_name[0] == '.')
|
||||
{
|
||||
// Skip hidden directories. (Prevents SVN bookkeeping
|
||||
// info from being included.)
|
||||
fts_set(fts, ent, FTS_SKIP);
|
||||
}
|
||||
if (ent->fts_info == FTS_D && ent->fts_level == 0)
|
||||
{
|
||||
tree = alloc_dir_tree(ent->fts_path);
|
||||
if (tree == NULL)
|
||||
{
|
||||
no_mem = 1;
|
||||
break;
|
||||
}
|
||||
tree->next = trees;
|
||||
trees = tree;
|
||||
}
|
||||
if (ent->fts_info != FTS_F)
|
||||
{
|
||||
// We're only interested in remembering files.
|
||||
continue;
|
||||
}
|
||||
// info from being included.)
|
||||
fts_set(fts, ent, FTS_SKIP);
|
||||
}
|
||||
if (ent->fts_info == FTS_D && ent->fts_level == 0)
|
||||
{
|
||||
tree = alloc_dir_tree(ent->fts_path);
|
||||
if (tree == NULL)
|
||||
{
|
||||
no_mem = 1;
|
||||
break;
|
||||
}
|
||||
tree->next = trees;
|
||||
trees = tree;
|
||||
}
|
||||
if (ent->fts_info != FTS_F)
|
||||
{
|
||||
// We're only interested in remembering files.
|
||||
continue;
|
||||
}
|
||||
file = alloc_file_entry("", ent->fts_path, ent->fts_statp->st_mtime);
|
||||
if (file == NULL)
|
||||
{
|
||||
|
@ -396,10 +397,10 @@ dir_tree_t *add_dirs(char **argv)
|
|||
}
|
||||
file->next = tree->files;
|
||||
tree->files = file;
|
||||
}
|
||||
fts_close(fts);
|
||||
return trees;
|
||||
}
|
||||
}
|
||||
fts_close(fts);
|
||||
return trees;
|
||||
}
|
||||
#endif
|
||||
|
||||
//==========================================================================
|
||||
|
@ -608,12 +609,10 @@ int append_to_zip(zipFile zipfile, const file_sorted_t *file)
|
|||
|
||||
int __cdecl main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
dir_tree_t *tree, *trees;
|
||||
file_entry_t *file;
|
||||
struct stat zipstat;
|
||||
int needwrite;
|
||||
char *s;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue