Commit f1bc081d authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

use sys_open and friends in most of the libs in purr-data/externals

parent 1d314a32
......@@ -49,7 +49,7 @@ static void matrix_load(t_matrix *x, t_symbol *s)
if(s && s->s_name)
{
post("matrix: loading %s",s->s_name);
if(matrix = fopen(s->s_name, "r"))
if(matrix = sys_fopen(s->s_name, "r"))
{
int n = x->x_ctl.c_order;
fread(x->x_ctl.c_A, sizeof(t_float), n*n, matrix);
......
......@@ -49,7 +49,7 @@ static void ascwave_open(t_ascwave *x, t_symbol *filename)
post("ascwave: open");
x->filename = filename;
post("ascwave: filename = %s",x->filename->s_name);
if ((x->x_file = fopen(x->filename->s_name,"w")) < 0)
if ((x->x_file = sys_fopen(x->filename->s_name,"w")) < 0)
{
error("can't create %s",filename->s_name);
return;
......
......@@ -200,7 +200,7 @@ static void *earplug_new(t_floatarg azimArg, t_floatarg elevArg)
fscanf(fp, "%f %f ", &earplug_impulses[i][0][j], &earplug_impulses[i][1][j]);
}
}
fclose(fp) ;
sys_fclose(fp) ;
}
x->impulses = earplug_impulses;
......
......@@ -52,9 +52,9 @@ void sfread_open(t_sfread *x,t_symbol *filename)
/* close the old file */
if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size);
if (x->x_fd >= 0) close(x->x_fd);
if (x->x_fd >= 0) sys_close(x->x_fd);
if ((x->x_fd = open(fname,O_RDONLY)) < 0)
if ((x->x_fd = sys_open(fname,O_RDONLY)) < 0)
{
error("can't open %s",fname);
return;
......
......@@ -140,7 +140,7 @@ static void sfwrite13_close(t_sfwrite13 *x)
sfwrite13_wave_setup(x,&w);
lseek(x->x_file,0,SEEK_SET);
write(x->x_file,&w,sizeof(w));
close(x->x_file);
sys_close(x->x_file);
}
x->x_file = -1;
}
......@@ -164,7 +164,7 @@ static void sfwrite13_open(t_sfwrite13 *x,t_symbol *filename)
sfwrite13_close(x);
if ((x->x_file = open(fname,OPENPARAMS,0664)) < 0)
if ((x->x_file = sys_open(fname,OPENPARAMS,0664)) < 0)
{
error("can't create %s",fname);
return;
......
......@@ -45,9 +45,9 @@ t_symbol *image_trytoopen(t_image* x)
canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
fname, FILENAME_MAX);
// try to open the file
if (file = fopen(fname, "r"))
if (file = sys_fopen(fname, "r"))
{
fclose(file);
sys_fclose(file);
return gensym(fname);
}
else
......
......@@ -90,7 +90,7 @@ void state_dosave(t_state *x)
else
sprintf(name,"%s%s.%d",dirstr,x->x_name->s_name,x->x_slot);
fp = fopen(name,"w");
fp = sys_fopen(name,"w");
if (!fp) {
post("state: unable to open %s",name);
return;
......@@ -151,7 +151,7 @@ void state_dosave(t_state *x)
} while ((a = (t_text*)((t_gobj*)a)->g_next));
post("state saved to: %s",name);
fclose(fp);
sys_fclose(fp);
}
......
......@@ -122,7 +122,7 @@ static void *vbap_new(t_symbol* s)
canvas_makefilename(canvas_getcurrent(),s->s_name,
fname,MAXPDSTRING);
if((fp=fopen(fname,"r"))==NULL){
if((fp=sys_fopen(fname,"r"))==NULL){
post("vbap: Could not open loudspeaker data file %s\n",fname);
x->opened = 0;
}
......@@ -130,7 +130,7 @@ static void *vbap_new(t_symbol* s)
if (!read_ls_conf(x,fp))
return NULL;
x->opened = 1;
fclose(fp);
sys_fclose(fp);
}
x->lasttrip[0] = 0;
......
......@@ -99,7 +99,7 @@ static void sfwrite_close(t_sfwrite *x)
sfwrite_wave_setup(x,&w);
lseek(x->x_file,0,SEEK_SET);
write(x->x_file,&w,sizeof(w));
close(x->x_file);
sys_close(x->x_file);
}
x->x_file = -1;
}
......@@ -123,7 +123,7 @@ static void sfwrite_open(t_sfwrite *x,t_symbol *filename)
sfwrite_close(x);
if ((x->x_file = open(fname,OPENPARAMS,0664)) < 0)
if ((x->x_file = sys_open(fname,OPENPARAMS,0664)) < 0)
{
error("can't create %s",fname);
return;
......
......@@ -79,7 +79,7 @@ void adaptation_write(const char *filename, t_int N, t_float mu, t_float *c)
int i;
// open file
f = fopen(filename, "w");
f = sys_fopen(filename, "w");
if(!f)
{
post("adaptive, save: error open file");
......@@ -96,7 +96,7 @@ void adaptation_write(const char *filename, t_int N, t_float mu, t_float *c)
fprintf(f, "%.30f\n", c[i]);
// close file
if (f) fclose(f);
if (f) sys_fclose(f);
post("adaptive, save: coefficients written to file");
}
......@@ -107,7 +107,7 @@ void adaptation_read(const char *filename, t_int *N, t_float *mu,
int i, n=0;
// open file
f = fopen(filename, "r");
f = sys_fopen(filename, "r");
if(!f)
{
post("adaptive, open: error open file");
......
......@@ -57,11 +57,11 @@ static t_symbol *iem_image_calc_size(t_iem_image *x)
else
{
if(fd >= 0)
close(fd);
sys_close(fd);
strcpy(namebuf, dirbuf);
strcat(namebuf, "/");
strcat(namebuf, namebufptr);
fh = fopen(namebuf, "r");
fh = sys_fopen(namebuf, "r");
if(fh == NULL)
{
post("iem_image-ERROR: cannot open %s second time", namebuf);
......@@ -76,7 +76,7 @@ static t_symbol *iem_image_calc_size(t_iem_image *x)
x->x_gifsym = (t_symbol *)0;
return((t_symbol *)0);
};
fclose(fh);
sys_fclose(fh);
c = (char *)buf;
if((c[0] != 'G')||(c[1] != 'I')||(c[2] != 'F'))
{
......
......@@ -3174,7 +3174,7 @@ static void *mp3play_tilde_new(void)
static void mp3play_tilde_cleanup(t_mp3play_tilde *x)
{
x->file_is_open = 0;
fclose(x->fh);
sys_fclose(x->fh);
x->play_state = 0;
x->mp3_out_index = 0;
x->mp_is_init = 0;
......@@ -3404,7 +3404,7 @@ static void mp3play_tilde_do_open(t_mp3play_tilde *x, char *str, int calc_it)
strcat(completefilename, str);
}
if((x->fh = fopen(completefilename, "rb")) == NULL)
if((x->fh = sys_fopen(completefilename, "rb")) == NULL)
{
post("mp3play-ERROR: cannot open %s", completefilename);
}
......@@ -3520,13 +3520,13 @@ static void mp3play_tilde_do_open(t_mp3play_tilde *x, char *str, int calc_it)
{
x->file_is_open = 0;
x->mp3_out_index = 0;
fclose(x->fh);
sys_fclose(x->fh);
}
}
else
{
x->file_is_open = 0;
fclose(x->fh);
sys_fclose(x->fh);
}
}
x->play_state = 2;
......
......@@ -99,7 +99,7 @@ static void soundfile_info_overwrite_sr(t_soundfile_info *x, t_symbol *filename,
strcat(completefilename, filename->s_name);
}
fh = fopen(completefilename,"r+b");
fh = sys_fopen(completefilename,"r+b");
if(!fh)
{
post("soundfile_info_read: cannot open %s !!\n", completefilename);
......@@ -187,7 +187,7 @@ static void soundfile_info_overwrite_sr(t_soundfile_info *x, t_symbol *filename,
fseek(fh,0,SEEK_SET);
read_chars = (int)fwrite (x->x_begmem, sizeof(char), n4, fh);
fclose(fh);
sys_fclose(fh);
post("written");
sr = (int)ul_sr;
......@@ -268,7 +268,7 @@ static void soundfile_info_read(t_soundfile_info *x, t_symbol *filename)
strcat(completefilename, filename->s_name);
}
fh = fopen(completefilename,"rb");
fh = sys_fopen(completefilename,"rb");
if(!fh)
{
post("soundfile_info_read: cannot open %s !!\n", completefilename);
......@@ -282,7 +282,7 @@ static void soundfile_info_read(t_soundfile_info *x, t_symbol *filename)
filesize = ftell(fh);
fseek(fh,0,SEEK_SET);
read_chars = (int)fread(x->x_begmem, sizeof(char), n4, fh) / 2;
fclose(fh);
sys_fclose(fh);
// post("read chars = %d", read_chars);
cvec = (char *)x->x_begmem;
if(read_chars > 4)
......
......@@ -88,7 +88,7 @@ static void iem_pbank_csv_write(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
strcat(completefilename, filename->s_name);
}
fh = fopen(completefilename,"wb");
fh = sys_fopen(completefilename,"wb");
if(!fh)
{
post("iem_pbank_csv_write: cannot create %s !!\n", completefilename);
......@@ -172,7 +172,7 @@ static void iem_pbank_csv_write(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
fprintf(fh, "%s%s", ap->a_w.w_symbol->s_name, eol+eol_offset);
ap++;
}
fclose(fh);
sys_fclose(fh);
post("iem_pbank_csv: wrote %d parameters x %d lines to file:\n%s\nwith following format:\n%s\n", nrp, nrl, completefilename, formattext);
}
}
......@@ -407,7 +407,7 @@ static void iem_pbank_csv_read(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
strcat(completefilename, filename->s_name);
}
fh = fopen(completefilename,"rb");
fh = sys_fopen(completefilename,"rb");
if(!fh)
{
post("iem_pbank_csv_read: cannot open %s !!\n", completefilename);
......@@ -481,7 +481,7 @@ static void iem_pbank_csv_read(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
txbuf2 = (char *)getbytes((2 * txalloc + 256) * sizeof(char));
if(fread(txbuf1, sizeof(char), txalloc, fh) < sizeof(char)*txalloc)
post("pbank.csv:435: warning read error (not specified)");
fclose(fh);
sys_fclose(fh);
// 1.) allow only readable ASCII (0x09, 0x0a, 0x0d, 0x20...0x7e =
// = TAB, LF, CR, ' ' ... '~' =
......
......@@ -141,7 +141,7 @@ void sigseq_readfile(t_sigseq *x, t_symbol *filename)
FILE *fp;
float data;
post("requested path: %s", filename->s_name);
fp = fopen(filename->s_name, "r");
fp = sys_fopen(filename->s_name, "r");
if( fp == NULL ){
post("could not open file!");
return;
......@@ -149,7 +149,7 @@ void sigseq_readfile(t_sigseq *x, t_symbol *filename)
while( fscanf(fp, "%f", &data) != EOF ){
post("%f",data);
}
fclose(fp);
sys_fclose(fp);
}
void sigseq_mute(t_sigseq *x, t_symbol *msg, short argc, t_atom *argv)
......
......@@ -43,7 +43,7 @@ static const char *image_get_filename(t_image *x, char *file)
retrieve the full path... */
fullpath = dirresult;
fullpath[strlen(fullpath)] = '/';
close(fd);
sys_close(fd);
return fullpath;
}
else return 0;
......
......@@ -523,12 +523,12 @@ static int create_soundfile2(t_canvas *canvas, const char *filename,
canvas_makefilename(canvas, filenamebuf, buf2, MAXPDSTRING);
sys_bashfilename(buf2, buf2);
if ((fd = open(buf2, BINCREATE, 0666)) < 0)
if ((fd = sys_open(buf2, BINCREATE, 0666)) < 0)
return (-1);
if (write(fd, headerbuf, headersize) < headersize)
{
close (fd);
sys_close (fd);
return (-1);
}
return (fd);
......@@ -914,7 +914,7 @@ static void soundfiler2_read(t_soundfiler2 *x, t_symbol *s,
/* do all graphics updates */
for (i = 0; i < argc; i++)
garray_redraw(garrays[i]);
fclose(fp);
sys_fclose(fp);
fd = -1;
goto done;
usage:
......@@ -923,7 +923,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, (float)itemsread);
}
......@@ -1029,7 +1029,7 @@ static long soundfiler2_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:
......@@ -1039,7 +1039,7 @@ usage:
post("(defaults to a 16-bit wave file).");
fail:
if (fd >= 0)
close (fd);
sys_close (fd);
return (0);
}
......@@ -1230,7 +1230,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)
......@@ -1383,7 +1383,7 @@ lost:
{
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;
}
......@@ -1396,7 +1396,7 @@ lost:
{
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;
}
......@@ -1410,7 +1410,7 @@ lost:
{
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;
}
......
......@@ -317,7 +317,7 @@ static void sfread_open(t_sfread *x,t_symbol *filename)
/* close the old file */
if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size);
if (x->x_fd >= 0) close(x->x_fd);
if (x->x_fd >= 0) sys_close(x->x_fd);
/*if ((x->x_fd = open(fname,O_RDONLY)) < 0)*/
//post("fname: %s",fname);
......
......@@ -27,12 +27,12 @@ int check_fileformat(t_symbol* file)
OggVorbis_File vorbisfile;
// partially opens a vorbis file to test for Vorbis-ness
if( !(fp = fopen(file->s_name, "r")) )
if( !(fp = sys_fopen(file->s_name, "r")) )
return -1;
if( ov_test(fp, &vorbisfile, NULL, 0) < 0 )
{
fclose(fp);
sys_fclose(fp);
return USE_LIBSNDFILE;
}
......@@ -145,12 +145,12 @@ int read_libvorbisfile(t_float** helper_arrays, int channel_count, int seek,
OggVorbis_File vorbisfile;
vorbis_info *info;
if( !(fp = fopen(file->s_name, "r")) )
if( !(fp = sys_fopen(file->s_name, "r")) )
return -1;
if( ov_open(fp, &vorbisfile, NULL, 0) < 0 )
{
fclose(fp);
sys_fclose(fp);
return -1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment