1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

patch to add binary mode on opening files (for Windows+Cygwin compatibility).

This commit is contained in:
dan
2002-09-15 20:37:41 +00:00
parent 3fc803c0d8
commit 92b012e800
20 changed files with 41 additions and 34 deletions

View File

@@ -6,6 +6,8 @@ Changes since version 0.80.1:
the root menu (sent by "Marc-Christian Petersen" <m.c.p@wolk-project.de>)
- Fixed dock's menu mapping position when dock is on the right side.
- Map clip's menu so that it never gets out of screen on the left or the right.
- Patch to add binary mode on opening files (needed for Windows with Cygwin)
(sent by luke <luke@posh.optushome.com.au>)
Changes since version 0.80.0:

View File

@@ -586,7 +586,7 @@ testText(WMScreen *scr)
{
WMWindow *win;
WMText *text;
FILE *file = fopen("wm.html", "r");
FILE *file = fopen("wm.html", "rb");
windowCount++;

View File

@@ -1593,7 +1593,7 @@ WMReadPropListFromFile(char *file)
struct stat stbuf;
size_t length;
f = fopen(file, "r");
f = fopen(file, "rb");
if (!f) {
/* let the user print the error message if he really needs to */
/*wsyserror(_("could not open domain file '%s' for reading"), file);*/
@@ -1672,7 +1672,7 @@ WMWritePropListToFile(WMPropList *plist, char *path, Bool atomically)
mask = umask(0);
umask(mask);
fchmod(fd, 0644 & ~mask);
if ((theFile = fdopen(fd, "w")) == NULL) {
if ((theFile = fdopen(fd, "wb")) == NULL) {
close(fd);
}
#else

View File

@@ -282,6 +282,10 @@ enum {
#define M_PI 3.14159265358979323846
#endif
/* Silly hack for Windows systems with cygwin */
#ifndef O_BINARY
# define O_BINARY 0
#endif
static int fetchFile(char* toPath, char *imageSrcFile,
char *imageDestFileName);
@@ -302,9 +306,9 @@ static WMPoint magnifyInitialize(W_ColorPanel *panel);
static void magnifyPutCursor(WMWidget *w, void *data);
static Pixmap magnifyCreatePixmap(WMColorPanel *panel);
static void magnifyGetImageStored(W_ColorPanel *panel, int x1, int y1,
int x2, int y2);
int x2, int y2);
static XImage* magnifyGetImage(WMScreen *scr, XImage *image, int x, int y,
int w, int h);
int w, int h);
static wheelMatrix* wheelCreateMatrix(unsigned int width , unsigned int height);
static void wheelDestroyMatrix(wheelMatrix *matrix);
@@ -1282,7 +1286,7 @@ readXColors(W_ColorPanel *panel)
return;
}
else {
if ((rgbtxt = fopen(RGBTXT, "r"))) {
if ((rgbtxt = fopen(RGBTXT, "rb"))) {
while (fgets(line, MAX_LENGTH, rgbtxt)) {
if (sscanf(line, "%d%d%d %[^\n]", &red, &green, &blue, name)) {
color = wmalloc(sizeof(RColor));
@@ -3644,13 +3648,13 @@ fetchFile(char *toPath, char *srcFile, char *destFile)
char *tmp;
char buf[BUFSIZE];
if ((src = open(srcFile, O_RDONLY)) == 0) {
if ((src = open(srcFile, O_RDONLY|O_BINARY)) == 0) {
wsyserror(_("Could not open %s"), srcFile);
return -1;
}
tmp = wstrconcat(toPath, destFile);
if ((dest = open( tmp, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH))
if ((dest = open( tmp, O_RDWR|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH))
== 0) {
wsyserror(_("Could not create %s"), tmp);
wfree(tmp);

View File

@@ -420,7 +420,7 @@ dumpRImage(char *path, RImage *image)
FILE *f;
int channels = (image->format == RRGBAFormat ? 4 : 3);
f = fopen(path, "w");
f = fopen(path, "wb");
if (!f) {
wsyserror(path);
return;
@@ -1352,7 +1352,7 @@ loadRImage(WMScreen *scr, char *path)
int w, h, d;
Pixmap pixmap;
f = fopen(path, "r");
f = fopen(path, "rb");
if (!f)
return None;

View File

@@ -701,9 +701,9 @@ storeCommandInScript(char *cmd, char *line)
path = wstrconcat(wusergnusteppath(), "/Library/WindowMaker/autostart");
f = fopen(path, "r");
f = fopen(path, "rb");
if (!f) {
f = fopen(path, "w");
f = fopen(path, "wb");
if (!f) {
wsyserror(_("could not create %s"), path);
goto end;
@@ -719,7 +719,7 @@ storeCommandInScript(char *cmd, char *line)
tmppath = wstrconcat(wusergnusteppath(),
"/Library/WindowMaker/autostart.tmp");
fo = fopen(tmppath, "w");
fo = fopen(tmppath, "wb");
if (!fo) {
wsyserror(_("could not create temporary file %s"), tmppath);
wfree(tmppath);

View File

@@ -1739,7 +1739,7 @@ connectKFM(WScreen *scr)
wfree(buffer);
/* pid file */
f = fopen(path, "r");
f = fopen(path, "rb");
wfree(path);
if (!f)
return -1;
@@ -1771,7 +1771,7 @@ connectKFM(WScreen *scr)
}
path = wstrconcat(wgethomedir(), "/.kde/share/apps/kfm/magic");
f = fopen(path, "r");
f = fopen(path, "rb");
wfree(path);
if (!f) {
return -1;

View File

@@ -202,7 +202,7 @@ static WRootMenuData *text_openMenuFile(char *path)
data = wmalloc(sizeof(TextMenuReaderData));
data->reader = TextMenuReader;
data->file = fopen(path, "r");
data->file = fopen(path, "rb");
if (!data->file) {
return NULL;

View File

@@ -1207,7 +1207,7 @@ readMenuFile(WScreen *scr, char *file_name)
#endif /* USECPP */
if (!file) {
file = fopen(file_name, "r");
file = fopen(file_name, "rb");
if (!file) {
wsyserror(_("%s:could not open menu file"), file_name);
return NULL;
@@ -1309,7 +1309,7 @@ readMenuPipe(WScreen *scr, char **file_name)
#endif /* USECPP */
if (!file) {
file = popen(filename, "r");
file = popen(filename, "rb");
if (!file) {
wsyserror(_("%s:could not open menu file"), filename);

View File

@@ -492,7 +492,7 @@ loadData(WScreen *scr)
RImage *image;
Pixmap d[12];
f = fopen(PKGDATADIR"/xtree.dat", "r");
f = fopen(PKGDATADIR"/xtree.dat", "rb");
if (!f)
return False;

View File

@@ -15,10 +15,7 @@ INCLUDES = $(DFLAGS) -I$(top_srcdir)/WINGs -I$(top_srcdir)/wrlib \
@HEADER_SEARCH_PATH@ \
-DETCDIR=\"sysconfdir\" -DDATADIR=\"pkgdatadir\"
# X_EXTRA_LIBS is for libproplist in systems that need -lsocket
# remove after we require lPL 0.10.2 which automatically resolves its
# library dependancies using the libPropList.la file
liblist= @LIBRARY_SEARCH_PATH@ @X_EXTRA_LIBS@ @INTLIBS@
liblist= @LIBRARY_SEARCH_PATH@ @INTLIBS@
wdwrite_LDADD = $(top_builddir)/WINGs/libWUtil.a $(liblist)

View File

@@ -133,7 +133,7 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height)
if (!canLoad(rc))
return None;
file = fopen(file_name, "r");
file = fopen(file_name, "rb");
if (!file) {
return None;
}

View File

@@ -595,7 +595,7 @@ readBlackBoxStyle(char *path)
char buffer[128], char token[128];
WMPropList *style, *p;
f = fopen(path, "r");
f = fopen(path, "rb");
if (!f) {
perror(path);
return NULL;

View File

@@ -296,7 +296,7 @@ Bool copyAllFiles(char *gsdir)
sprintf(path, "%s/USER_FILES", DATADIR);
f = fopen(path, "r");
f = fopen(path, "rb");
while (!feof(f)) {
if (!fgets(file, 255, f)) {
break;
@@ -319,7 +319,7 @@ Bool copyAllFiles(char *gsdir)
sprintf(path, "%s/USER_FILES", ETCDIR);
f = fopen(path, "r");
f = fopen(path, "rb");
while (!feof(f)) {
if (!fgets(path, 255, f)) {
break;

View File

@@ -120,7 +120,7 @@ main(int argc, char **argv)
}
}
if (filename) {
file = fopen(filename, "r");
file = fopen(filename, "rb");
if (!file) {
char line[1024];
sprintf(line, "%s: could not open \"%s\"", argv[0], filename);

View File

@@ -109,7 +109,7 @@ RLoadJPEG(RContext *context, char *file_name, int index)
*/
struct my_error_mgr jerr;
file = fopen(file_name, "r");
file = fopen(file_name, "rb");
if (!file) {
RErrorCode = RERR_OPEN;
return NULL;

View File

@@ -37,6 +37,10 @@
#include "wraster.h"
/* Silly hack for Windows systems with cygwin */
#ifndef O_BINARY
# define O_BINARY 0
#endif
typedef struct RCachedImage {
RImage *image;
@@ -321,7 +325,7 @@ identFile(char *path)
assert(path!=NULL);
fd = open(path, O_RDONLY);
fd = open(path, O_RDONLY|O_BINARY);
if (fd < 0) {
RErrorCode = RERR_OPEN;
return IM_ERROR;

View File

@@ -245,7 +245,7 @@ RLoadXPM(RContext *context, char *file, int index)
int w, h, ccount, csize;
FILE *f;
f = fopen(file, "r");
f = fopen(file, "rb");
if (!f) {
RErrorCode = RERR_OPEN;
return NULL;
@@ -569,7 +569,7 @@ RSaveXPM(RImage *image, char *filename)
char transp[16];
char buf[128];
file = fopen(filename, "w+");
file = fopen(filename, "wb+");
if (!file) {
RErrorCode = RERR_OPEN;
return False;

View File

@@ -67,7 +67,7 @@ RLoadPNG(RContext *context, char *file, int index)
png_bytep *png_rows;
unsigned char *ptr;
f = fopen(file, "r");
f = fopen(file, "rb");
if (!f) {
RErrorCode = RERR_OPEN;
return NULL;

View File

@@ -127,7 +127,7 @@ RLoadPPM(RContext *context, char *file_name, int index)
#define GETL() if (!fgets(buffer, 255, file)) goto short_file
file = fopen(file_name, "r");
file = fopen(file_name, "rb");
if (!file) {
RErrorCode = RERR_OPEN;
return NULL;