Exemple #1
0
/* Open the source file for reading, closing any previously open file.
   If dir_list is not NULL, calls search_file() to search the file in dir_list */
Bool SrcFile_open( SrcFile *self, char *filename, UT_array *dir_list )
{
    char *filename_path;
	
	/* close last file */
	if (self->file != NULL)
	{
		myfclose(self->file);
		self->file = NULL;
	}

	/* search path, add to strpool */
	filename_path = search_file(filename, dir_list);

	/* check for recursive includes, return if found */
	if (!check_recursive_include(self, filename_path))
		return FALSE;
	
	self->filename = filename_path;

    /* open new file in binary mode, for cross-platform newline processing */
    self->file = myfopen( self->filename, "rb" );

	/* init current line */
    str_clear( self->line );
    self->line_nr = 0;

	if (self->file)
		return TRUE;
	else
		return FALSE;		/* error opening file */
}
Exemple #2
0
/* Open the source file for reading, closing any previously open file.
   If dir_list is not NULL, calls path_search() to search the file in dir_list */
bool SrcFile_open( SrcFile *self, const char *filename, UT_array *dir_list )
{
	/* close last file */
	if (self->file != NULL)
	{
		xfclose(self->file);
		self->file = NULL;
	}

	/* search path, add to strpool */
	const char *filename_path = path_search(filename, dir_list);

	/* check for recursive includes, return if found */
	if (!check_recursive_include(self, filename_path))
		return false;
	
	self->filename = filename_path;
	self->line_filename = filename_path;

    /* open new file in binary mode, for cross-platform newline processing */
    self->file = fopen( self->filename, "rb" );
	if (!self->file)
		error_read_file(self->filename);

	/* init current line */
    Str_clear( self->line );
    self->line_nr = 0;
	self->line_inc = 1;
	self->is_c_source = false;

	if (self->file)
		return true;
	else
		return false;		/* error opening file */
}