Skip to content

Commit

Permalink
Don't use redirection to create ndata
Browse files Browse the repository at this point in the history
 - fixes bug where make ndata fails and an empty file is created
Use "ndata.zip" instead of "ndata" for clarity
  • Loading branch information
BrknRobot committed Jun 25, 2014
1 parent 8269519 commit 2d30ec5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 2 additions & 4 deletions Makefile.am
Expand Up @@ -16,7 +16,7 @@ dist_pkgdata_DATA = naev-confupdate.sh
dist_man6_MANS = naev.6
dist_doc_DATA = AUTHORS README TODO LICENSE

DATA_ARCHIVE = ndata
DATA_ARCHIVE = ndata.zip
if HAVE_UTILS
MKSPR = utils/mkspr/mkspr$(EXEEXT)
endif
Expand Down Expand Up @@ -45,9 +45,7 @@ $(MKSPR):
$(DATA_ARCHIVE): VERSION
@echo " ZIP $(DATA_ARCHIVE)"
cd "$(top_srcdir)" && \
(find AUTHORS VERSION naev-confupdate.sh -print0; \
find dat -type f -print0) | xargs -0 \
zip -0rq - -@ > "$(abs_top_builddir)/$(DATA_ARCHIVE)";
zip -0r "$(abs_top_builddir)/$(DATA_ARCHIVE)" AUTHORS VERSION naev-confupdate.sh dat/
else
utils:

Expand Down
24 changes: 13 additions & 11 deletions src/ndata.c
Expand Up @@ -321,6 +321,7 @@ static char *ndata_findInDir( const char *path )
static int ndata_openFile (void)
{
char path[PATH_MAX], *buf;
char pathname[PATH_MAX];

/* Must be thread safe. */
SDL_mutexP(ndata_lock);
Expand All @@ -342,19 +343,20 @@ static int ndata_openFile (void)

/* Check ndata with version appended. */
#if VREV < 0
if (ndata_isndata("%s-%d.%d.0-beta%d", NDATA_FILENAME,
VMAJOR, VMINOR, ABS(VREV) )) {
ndata_filename = malloc(PATH_MAX);
nsnprintf( ndata_filename, PATH_MAX, "%s-%d.%d.0-beta%d",
NDATA_FILENAME, VMAJOR, VMINOR, ABS(VREV) );
}
nsnprintf ( pathname, PATH_MAX, "%s-%d.%d.0-beta%d", NDATA_FILENAME, VMAJOR, VMINOR, ABS ( VREV ) );
#else /* VREV < 0 */
if (ndata_isndata("%s-%d.%d.%d", NDATA_FILENAME, VMAJOR, VMINOR, VREV )) {
ndata_filename = malloc(PATH_MAX);
nsnprintf( ndata_filename, PATH_MAX, "%s-%d.%d.%d",
NDATA_FILENAME, VMAJOR, VMINOR, VREV );
}
nsnprintf ( pathname, PATH_MAX, "%s-%d.%d.%d", NDATA_FILENAME, VMAJOR, VMINOR, VREV );
#endif /* VREV < 0 */

if ( ndata_isndata ( pathname ) ) {
ndata_filename = malloc ( PATH_MAX );
strcpy ( ndata_filename, pathname );
}
else if ( ndata_isndata ( strcat(pathname, ".zip" )) ) {
ndata_filename = malloc ( PATH_MAX );
strcpy ( ndata_filename, pathname );
}

/* Check default ndata. */
else if (ndata_isndata(NDATA_DEF))
ndata_filename = strdup(NDATA_DEF);
Expand Down

0 comments on commit 2d30ec5

Please sign in to comment.