diff --git a/pd/src/d_soundfile.c b/pd/src/d_soundfile.c index e76cbad8c77574cb19bba228cd187453a801ebd7..e59b558f7778e5dd3577d4151e285f33b75e2f67 100644 --- a/pd/src/d_soundfile.c +++ b/pd/src/d_soundfile.c @@ -9,7 +9,7 @@ These operations are not to be done in "real time" as they may have to wait for disk accesses (even the write routine.) Finally, the realtime objects readsf~ and writesf~ are defined which confine disk operations to a separate thread so that they can be used in real time. The readsf~ and writesf~ -objects use Posix-like threads. */ +objects use Posix-like threads. */ #include "config.h" @@ -38,10 +38,10 @@ objects use Posix-like threads. */ #ifdef _LARGEFILE64_SOURCE # define open open64 # define lseek lseek64 -#define off_t __off64_t +# define off_t __off64_t #endif #ifdef MSW -#define off_t long +# define off_t long #endif /***************** soundfile header structures ************************/ @@ -869,7 +869,7 @@ static int create_soundfile(t_canvas *canvas, const char *filename, if (write(fd, headerbuf, headersize) < headersize) { - close (fd); + sys_close (fd); return (-1); } return (fd); @@ -1382,7 +1382,7 @@ usage: post("-raw <headerbytes> <channels> <bytespersamp> <endian (b, l, or n)>."); done: if (fd >= 0) - close (fd); + sys_close(fd); outlet_float(x->x_obj.ob_outlet, (t_float)itemsread); } @@ -1487,7 +1487,7 @@ long soundfiler_dowrite(void *obj, t_canvas *canvas, { soundfile_finishwrite(obj, filesym->s_name, fd, filetype, nframes, itemswritten, nchannels * bytespersamp, swap); - close (fd); + sys_close(fd); } return ((float)itemswritten); usage: @@ -1497,7 +1497,7 @@ usage: post("(defaults to a 16-bit wave file)."); fail: if (fd >= 0) - close (fd); + sys_close(fd); return (0); } @@ -1680,7 +1680,7 @@ static void *readsf_child_main(void *zz) { fd = x->x_fd; pthread_mutex_unlock(&x->x_mutex); - close (fd); + sys_close(fd); pthread_mutex_lock(&x->x_mutex); x->x_fd = -1; if (x->x_requestcode != REQUEST_BUSY) @@ -1863,7 +1863,7 @@ static void *readsf_child_main(void *zz) { fd = x->x_fd; pthread_mutex_unlock(&x->x_mutex); - close (fd); + sys_close(fd); pthread_mutex_lock(&x->x_mutex); x->x_fd = -1; } @@ -1876,7 +1876,7 @@ static void *readsf_child_main(void *zz) { fd = x->x_fd; pthread_mutex_unlock(&x->x_mutex); - close (fd); + sys_close(fd); pthread_mutex_lock(&x->x_mutex); x->x_fd = -1; } @@ -1890,7 +1890,7 @@ static void *readsf_child_main(void *zz) { fd = x->x_fd; pthread_mutex_unlock(&x->x_mutex); - close (fd); + sys_close(fd); pthread_mutex_lock(&x->x_mutex); x->x_fd = -1; } @@ -2246,7 +2246,7 @@ static void *writesf_child_main(void *zz) soundfile_finishwrite(x, filename, fd, filetype, 0x7fffffff, itemswritten, bytesperframe, swap); - close (fd); + sys_close(fd); pthread_mutex_lock(&x->x_mutex); x->x_fd = -1; @@ -2387,7 +2387,7 @@ static void *writesf_child_main(void *zz) soundfile_finishwrite(x, filename, fd, filetype, 0x7fffffff, itemswritten, bytesperframe, swap); - close (fd); + sys_close(fd); pthread_mutex_lock(&x->x_mutex); x->x_fd = -1; diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c index 3a86bfb37fcffeaa7a613ce2d916f4e35440d6f8..53f07c4c74daa6722456c7168f968ee1d9d1f690 100644 --- a/pd/src/m_binbuf.c +++ b/pd/src/m_binbuf.c @@ -964,13 +964,13 @@ int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag) int readret; char *buf; char namebuf[MAXPDSTRING]; - + if (*dirname) snprintf(namebuf, MAXPDSTRING-1, "%s/%s", dirname, filename); else snprintf(namebuf, MAXPDSTRING-1, "%s", filename); namebuf[MAXPDSTRING-1] = 0; - + if ((fd = sys_open(namebuf, 0)) < 0) { //fprintf(stderr, "open: "); @@ -982,14 +982,14 @@ int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag) { //fprintf(stderr, "lseek: "); perror(namebuf); - close(fd); + sys_close(fd); return(1); } if ((readret = read(fd, buf, length)) < length) { //fprintf(stderr, "read (%d %ld) -> %d\n", fd, length, readret); perror(namebuf); - close(fd); + sys_close(fd); t_freebytes(buf, length); return(1); } @@ -1008,7 +1008,7 @@ int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag) #endif t_freebytes(buf, length); - close(fd); + sys_close(fd); return (0); } @@ -1024,7 +1024,7 @@ int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, error("%s: can't open", filename); return (1); } - else close (filedesc); + else sys_close(filedesc); if (binbuf_read(b, bufptr, buf, crflag)) return (1); else return (0); @@ -1042,7 +1042,7 @@ int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname, error("%s: can't open", filename); return (1); } - else close (filedesc); + else sys_close(filedesc); if (binbuf_read(b, bufptr, buf, crflag)) return (1); else return (0); diff --git a/pd/src/s_file.c b/pd/src/s_file.c index acc8fa447598a7f9c026b84de807c623c8712a7e..be8b87958b361b1f40424a41f4e3030f43047b12 100644 --- a/pd/src/s_file.c +++ b/pd/src/s_file.c @@ -72,7 +72,7 @@ static void sys_initloadpreferences( void) else return; filenamebuf[FILENAME_MAX-1] = 0; - if ((fd = open(filenamebuf, 0)) < 0) + if ((fd = sys_open(filenamebuf, 0)) < 0) { if (sys_verbose) perror(filenamebuf); @@ -83,14 +83,14 @@ static void sys_initloadpreferences( void) { if (sys_verbose) perror(filenamebuf); - close(fd); + sys_close(fd); return; } lseek(fd, 0, 0); if (!(sys_prefbuf = malloc(length + 2))) { error("couldn't allocate memory for preferences buffer"); - close(fd); + sys_close(fd); return; } sys_prefbuf[0] = '\n'; @@ -98,11 +98,11 @@ static void sys_initloadpreferences( void) { perror(filenamebuf); sys_prefbuf[0] = 0; - close(fd); + sys_close(fd); return; } sys_prefbuf[length+1] = 0; - close(fd); + sys_close(fd); if (sys_verbose) post("success reading preferences from: %s", filenamebuf); } @@ -156,7 +156,7 @@ static void sys_initsavepreferences( void) } snprintf(filenamebuf, FILENAME_MAX, "%s/" USER_CONFIG_DIR "/user.settings", homedir); filenamebuf[FILENAME_MAX-1] = 0; - if ((sys_prefsavefp = fopen(filenamebuf, "w")) == NULL) + if ((sys_prefsavefp = sys_fopen(filenamebuf, "w")) == NULL) { //snprintf(errbuf, FILENAME_MAX, "%s: %s",filenamebuf, strerror(errno)); pd_error(0, "%s: %s",filenamebuf, strerror(errno)); @@ -883,7 +883,7 @@ void sys_save_recent_files(void) } snprintf(filenamebuf, FILENAME_MAX, "%s/" USER_CONFIG_DIR "/recent_files", homedir); filenamebuf[FILENAME_MAX-1] = 0; - if ((fp = fopen(filenamebuf, "w")) == NULL) { + if ((fp = sys_fopen(filenamebuf, "w")) == NULL) { pd_error(0, "%s: %s",filenamebuf, strerror(errno)); return; } @@ -914,7 +914,7 @@ void sys_load_recent_files(void) if (!homedir) return; snprintf(filenamebuf, FILENAME_MAX, "%s/" USER_CONFIG_DIR "/recent_files", homedir); filenamebuf[FILENAME_MAX-1] = 0; - if ((fp = fopen(filenamebuf, "r")) == NULL) return; + if ((fp = sys_fopen(filenamebuf, "r")) == NULL) return; for (sys_n_recent_files = 0; sys_n_recent_files < MAX_RECENT_FILES && fgets(filenamebuf, FILENAME_MAX, fp); ) { char *s; diff --git a/pd/src/s_loader.c b/pd/src/s_loader.c index 7039aa4b9a5f8509f3ac8e2fd4cf647dbe9b87aa..d927daa2964dcc75b72ace5e5797bd29f69a9bf8 100644 --- a/pd/src/s_loader.c +++ b/pd/src/s_loader.c @@ -219,7 +219,7 @@ static int sys_do_load_lib(t_canvas *canvas, const char *objectname, #endif return (0); gotone: - close(fd); + sys_close(fd); class_set_extern_dir(gensym(dirbuf)); /* rebuild the absolute pathname */ @@ -444,7 +444,6 @@ int sys_run_scheduler(const char *externalschedlibname, } } - /* abstraction loading */ void canvas_popabstraction(t_canvas *x); int pd_setloadingabstraction(t_symbol *sym); @@ -474,7 +473,7 @@ static t_pd *do_create_abstraction(t_symbol*s, int argc, t_atom *argv) (fd = canvas_open(canvas, classslashclass, ".pd", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) { - close(fd); + sys_close(fd); canvas_setargs(argc, argv); binbuf_evalfile(gensym(nameptr), gensym(dirbuf)); @@ -510,11 +509,11 @@ static int sys_do_load_abs(t_canvas *canvas, const char *objectname, (fd = sys_trytoopenone(path, classslashclass, ".pd", dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) { - t_class*c=0; - close(fd); + t_class *c = 0; + sys_close(fd); /* found an abstraction, now register it as a new pseudo-class */ class_set_extern_dir(gensym(dirbuf)); - if((c=class_new(gensym(objectname), + if ((c=class_new(gensym(objectname), (t_newmethod)do_create_abstraction, 0, 0, 0, A_GIMME, 0))) { diff --git a/pd/src/s_main.c b/pd/src/s_main.c index 975e42dc97c9d9ae7c9d5284dc1f932e00163ff2..62ad4dc69ab4f64d511db9bfa4ff1a052d79625d 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -172,7 +172,7 @@ static void openit(const char *dirname, const char *filename) FILENAME_MAX, 0); if (fd >= 0) { - close (fd); + sys_close(fd); glob_evalfile(0, gensym(nameptr), gensym(dirbuf)); gui_vmess("gui_process_open_arg", "s", filename); }