mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 06:41:41 +00:00
- Added Blzut's zipdir compatibility patch for Solaris.
SVN r2020 (trunk)
This commit is contained in:
parent
20e265f8fb
commit
9522d81cd7
1 changed files with 98 additions and 2 deletions
|
@ -36,8 +36,10 @@
|
|||
#define stat _stat
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#if !defined(__sun)
|
||||
#include <fts.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -131,7 +133,10 @@ typedef unsigned int DWORD;
|
|||
typedef unsigned short WORD;
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
#pragma pack(push,1)
|
||||
// [BL] Solaris (well GCC on Solaris) doesn't seem to support pack(push/pop, 1) so we'll need to use use it
|
||||
// on the whole file.
|
||||
#pragma pack(1)
|
||||
//#pragma pack(push,1)
|
||||
typedef struct
|
||||
{
|
||||
DWORD Magic; // 0
|
||||
|
@ -179,7 +184,7 @@ typedef struct
|
|||
DWORD DirectoryOffset;
|
||||
WORD ZipCommentLength;
|
||||
} EndOfCentralDirectory;
|
||||
#pragma pack(pop)
|
||||
//#pragma pack(pop)
|
||||
|
||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||
|
||||
|
@ -484,6 +489,97 @@ dir_tree_t *add_dirs(char **argv)
|
|||
return trees;
|
||||
}
|
||||
|
||||
#elif defined(__sun)
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// add_dirs
|
||||
// Solaris version
|
||||
//
|
||||
// Given NULL-terminated array of directory paths, create trees for them.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void add_dir(dir_tree_t *tree, char* dirpath)
|
||||
{
|
||||
DIR *directory = opendir(dirpath);
|
||||
if(directory == NULL)
|
||||
return;
|
||||
|
||||
struct dirent *file;
|
||||
while((file = readdir(directory)) != NULL)
|
||||
{
|
||||
if(file->d_name[0] == '.') //File is hidden or ./.. directory so ignore it.
|
||||
continue;
|
||||
|
||||
int isDirectory = 0;
|
||||
int time = 0;
|
||||
|
||||
char* fullFileName = malloc(strlen(dirpath) + strlen(file->d_name) + 1);
|
||||
strcpy(fullFileName, dirpath);
|
||||
strcat(fullFileName, file->d_name);
|
||||
|
||||
struct stat *fileStat;
|
||||
fileStat = malloc(sizeof(struct stat));
|
||||
stat(fullFileName, fileStat);
|
||||
isDirectory = S_ISDIR(fileStat->st_mode);
|
||||
time = fileStat->st_mtime;
|
||||
free(stat);
|
||||
|
||||
free(fullFileName);
|
||||
|
||||
if(isDirectory)
|
||||
{
|
||||
char* newdir;
|
||||
newdir = malloc(strlen(dirpath) + strlen(file->d_name) + 2);
|
||||
strcpy(newdir, dirpath);
|
||||
strcat(newdir, file->d_name);
|
||||
strcat(newdir, "/");
|
||||
add_dir(tree, newdir);
|
||||
free(newdir);
|
||||
continue;
|
||||
}
|
||||
|
||||
file_entry_t *entry;
|
||||
entry = alloc_file_entry(dirpath, file->d_name, time);
|
||||
if (entry == NULL)
|
||||
{
|
||||
//no_mem = 1;
|
||||
break;
|
||||
}
|
||||
entry->next = tree->files;
|
||||
tree->files = entry;
|
||||
}
|
||||
|
||||
closedir(directory);
|
||||
}
|
||||
|
||||
dir_tree_t *add_dirs(char **argv)
|
||||
{
|
||||
dir_tree_t *tree, *trees = NULL;
|
||||
|
||||
int i = 0;
|
||||
while(argv[i] != NULL)
|
||||
{
|
||||
tree = alloc_dir_tree(argv[i]);
|
||||
tree->next = trees;
|
||||
trees = tree;
|
||||
|
||||
if(tree != NULL)
|
||||
{
|
||||
char* dirpath = malloc(sizeof(argv[i]) + 2);
|
||||
strcpy(dirpath, argv[i]);
|
||||
if(dirpath[strlen(dirpath)] != '/')
|
||||
strcat(dirpath, "/");
|
||||
add_dir(tree, dirpath);
|
||||
free(dirpath);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue