Beispiel #1
0
Datei: file.c Projekt: liumch/src
void sf_fileclose (sf_file file) 
/*< close a file and free allocated space >*/
{
    if (NULL == file) return;
    
    if (file->stream != stdin && 
	file->stream != stdout && 
	file->stream != NULL) {
	(void) fclose (file->stream);
	file->stream = NULL;
    }
	
    if (file->head != NULL) {
	(void) unlink (file->headname);
	(void) fclose (file->head);
	file->head = NULL;
	free(file->headname);
	file->headname = NULL;
    }
	
    if (NULL != file->pars) {
	sf_simtab_close (file->pars);
	file->pars = NULL;
    }
	
    if (NULL != file->buf) {
	free (file->buf);
	file->buf = NULL;
    }
	
    if (NULL != file->dataname) {
	free (file->dataname);
	file->dataname = NULL;
    }
}
Beispiel #2
0
Datei: file.c Projekt: liumch/src
void sf_setpars (sf_file file)
/*< change parameters to those from the command line >*/
{
    char *in;
	
    in = sf_histstring(file,"in");
    sf_simtab_close(file->pars);
    file->pars = sf_getpars();
	
    if (NULL != in) {
	sf_putstring(file,"in",in);
	free(in);
    }
}
Beispiel #3
0
void sf_fileclosedelete (sf_file file)
/*< close a file and then delete the file from disk >*/
{
    if (NULL == file) return;

    if (file->stream != stdin &&
    file->stream != stdout &&
    file->stream != NULL) {
    (void) fclose (file->stream);
    file->stream = NULL;
    }

    if (file->head != NULL) {
    (void) unlink (file->headname);
    (void) fclose (file->head);
    file->head = NULL;
    remove(file->headname);
    free(file->headname);
    file->headname = NULL;
    }

    if (NULL != file->pars) {
    sf_simtab_close (file->pars);
    file->pars = NULL;
    }

    if (NULL != file->buf) {
    free (file->buf);
    file->buf = NULL;
    }

    if (NULL != file->dataname) {
    remove (file->dataname);
    free (file->dataname);
    file->dataname = NULL;
    }
}