[xiph-cvs] cvs commit: vorbis-tools/oggenc oggenc.c platform.c
Michael Smith
msmith at xiph.org
Mon Jan 28 20:39:26 PST 2002
msmith 02/01/28 20:39:25
Modified: oggenc oggenc.c platform.c
Log:
win32 updates.
win32 now works apart from the gettext stuff which segher left broken.
Revision Changes Path
1.48 +3 -2 vorbis-tools/oggenc/oggenc.c
Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- oggenc.c 2002/01/28 06:29:22 1.47
+++ oggenc.c 2002/01/29 04:39:25 1.48
@@ -16,6 +16,7 @@
#include <string.h>
#include <time.h>
#include <locale.h>
+#include <errno.h>
#include "platform.h"
#include "encode.h"
@@ -162,7 +163,7 @@
if(in == NULL)
{
- fprintf(stderr, _("ERROR: Cannot open input file \"%s\"\n"), infiles[i]);
+ fprintf(stderr, _("ERROR: Cannot open input file \"%s\": %s\n"), infiles[i], strerror(errno));
free(out_fn);
errors++;
continue;
@@ -264,7 +265,7 @@
{
if(closein)
fclose(in);
- fprintf(stderr, _("ERROR: Cannot open output file \"%s\"\n"), out_fn);
+ fprintf(stderr, _("ERROR: Cannot open output file \"%s\": %s\n"), out_fn, strerror(errno));
errors++;
free(out_fn);
continue;
<p><p>1.7 +34 -15 vorbis-tools/oggenc/platform.c
Index: platform.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/platform.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- platform.c 2002/01/28 06:29:22 1.6
+++ platform.c 2002/01/29 04:39:25 1.7
@@ -67,20 +67,10 @@
free((time_t *)timer);
}
-int create_directories(char *fn)
-{
- /* FIXME: Please implement me */
- return 0;
-}
-
#else /* unix. Or at least win32 */
#include <sys/time.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <string.h>
void *timer_start(void)
{
@@ -105,45 +95,74 @@
free((time_t *)timer);
}
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef _WIN32
+
+#include <direct.h>
+
+#define PATH_SEPS "/\\"
+#define stat _stat
+#define mkdir(x,y) _mkdir((x))
+
+#else
+
+#define PATH_SEPS "/"
+
+#endif
+
int create_directories(char *fn)
{
char *end, *start;
struct stat statbuf;
- char segment[FILENAME_MAX];
+ char *segment = malloc(strlen(fn)+1);
start = fn;
- while((end = strchr(start+1, '/')) != NULL)
+ while((end = strpbrk(start+1, PATH_SEPS)) != NULL)
{
memcpy(segment, fn, end-fn);
- segment[end-fn+1] = 0;
+ segment[end-fn] = 0;
if(stat(segment,&statbuf)) {
if(errno == ENOENT) {
if(mkdir(segment, 0777)) {
fprintf(stderr, _("Couldn't create directory \"%s\": %s\n"),
- segment, strerror(errno));
+ segment, strerror(errno));
+ free(segment);
return -1;
}
}
else {
fprintf(stderr, _("Error checking for existence of directory %s: %s\n"),
segment, strerror(errno));
+ free(segment);
return -1;
}
}
+#ifdef _WIN32
+ else if(!(_S_IFDIR & statbuf.st_mode)) {
+#else
else if(!S_ISDIR(statbuf.st_mode)) {
+#endif
fprintf(stderr, _("Error: path segment \"%s\" is not a directory\n"),
segment);
+ free(segment);
+ return -1;
}
start = end+1;
}
+ free(segment);
return 0;
}
-#endif
<p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list