libgeda

f_basic.c File Reference

file related functions More...

#include <config.h>
#include <stdio.h>
#include <sys/param.h>
#include <limits.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "libgeda_priv.h"
Include dependency graph for f_basic.c:

Go to the source code of this file.

Defines

#define ROOT_MARKER_LEN   1

Functions

gchar * f_get_autosave_filename (const gchar *filename)
 Get the autosave filename for a file.
gboolean f_has_active_autosave (const gchar *filename, GError **err)
 Check if a file has an active autosave file.
int f_open (TOPLEVEL *toplevel, PAGE *page, const gchar *filename, GError **err)
 Opens the schematic file.
int f_open_flags (TOPLEVEL *toplevel, PAGE *page, const gchar *filename, const gint flags, GError **err)
 Opens the schematic file with fine-grained control over behaviour.
void f_close (TOPLEVEL *toplevel)
 Closes the schematic file.
int f_save (TOPLEVEL *toplevel, PAGE *page, const char *filename, GError **err)
 Save the schematic file.
gchar * f_normalize_filename (const gchar *name, GError **error)
 Builds an absolute pathname.
char * follow_symlinks (const gchar *filename, GError **err)
 Follow symlinks until a real file is found.

Detailed Description

Definition in file f_basic.c.


Define Documentation

#define ROOT_MARKER_LEN   1

Function Documentation

gchar* f_get_autosave_filename ( const gchar *  filename)
Function description
Returns the expected autosave filename for the filename passed.
Warning:
The result should be freed when no longer needed.
Parameters:
[in]filenameThe filename to create an autosave filename for.
Returns:
A newly allocated string buffer.

Definition at line 67 of file f_basic.c.

gboolean f_has_active_autosave ( const gchar *  filename,
GError **  err 
)
Function Description
Checks whether an autosave file exists for the filename passed which has a modification time newer than the file itself. If the check fails, sets err with the reason. N.b. if the autosave file exists but it was not possible to get its modification time, returns TRUE.
Parameters:
[in]filenameFile to check
[in,out]err#GError structure for error reporting, or NULL to disable error reporting
Returns:
TRUE if autosave active, FALSE otherwise

Definition at line 97 of file f_basic.c.

Here is the call graph for this function:

int f_open ( TOPLEVEL toplevel,
PAGE page,
const gchar *  filename,
GError **  err 
)
Function Description
Opens the schematic file by calling f_open_flags() with the F_OPEN_RC and F_OPEN_CHECK_BACKUP flags.
Parameters:
[in,out]toplevelThe TOPLEVEL object to load the schematic into.
[in]filenameA character string containing the file name to open.
[in,out]err#GError structure for error reporting, or NULL to disable error reporting
Returns:
0 on failure, 1 on success.

Definition at line 165 of file f_basic.c.

Here is the call graph for this function:

int f_open_flags ( TOPLEVEL toplevel,
PAGE page,
const gchar *  filename,
const gint  flags,
GError **  err 
)
Function Description
Opens the schematic file and carries out a number of actions depending on the flags set. If F_OPEN_RC is set, executes configuration files found in the target directory. If F_OPEN_CHECK_BACKUP is set, warns user if a backup is found for the file being loaded, and possibly prompts user for whether to load the backup instead. If F_OPEN_RESTORE_CWD is set, does not change the working directory to that of the file being loaded.
Parameters:
[in,out]toplevelThe TOPLEVEL object to load the schematic into.
[in]filenameA character string containing the file name to open.
[in]flagsCombination of FOpenFlags values.
[in,out]err#GError structure for error reporting, or NULL to disable error reporting
Returns:
0 on failure, 1 on success.

Definition at line 191 of file f_basic.c.

Here is the call graph for this function:

void f_close ( TOPLEVEL toplevel)
Function Description
Does nothing
Parameters:
[in,out]toplevelThe TOPLEVEL object with schematic to be closed.

Definition at line 341 of file f_basic.c.

int f_save ( TOPLEVEL toplevel,
PAGE page,
const char *  filename,
GError **  err 
)
Function Description
This function saves the current schematic file in the toplevel object.
Bug:
g_access introduces a race condition in certain cases, but solves bug #698565 in the normal use-case
Parameters:
[in,out]toplevelThe TOPLEVEL object containing the schematic.
[in]filenameThe file name to save the schematic to.
[in,out]err#GError structure for error reporting, or NULL to disable error reporting
Returns:
1 on success, 0 on failure.

Definition at line 359 of file f_basic.c.

Here is the call graph for this function:

gchar* f_normalize_filename ( const gchar *  name,
GError **  error 
)
Function Description
This function derives an absolute pathname for the pathname pointed to by name with '.' and '..' resolved. It does not resolve symbolic links.

It returns NULL and sets the error (if not NULL) if it failed to build the pathname or the pathname does not exists.

Note:
The code for this function is derived from the realpath() of the GNU C Library (Copyright (C) 1996-2002, 2004, 2005, 2006 Free Software Foundation, Inc. / LGPL 2.1 or later).

The part for the resolution of symbolic links has been discarded and it has been adapted for glib and for use on Windows.

Parameters:
[in]nameA character string containing the pathname to resolve.
[in,out]errorReturn location for a GError, or NULL.
Returns:
A newly-allocated string with the resolved absolute pathname on success, NULL otherwise.

Definition at line 510 of file f_basic.c.

char* follow_symlinks ( const gchar *  filename,
GError **  err 
)
Function Description
Does readlink() recursively until we find a real filename.
Parameters:
[in]filenameThe filename to search for.
[in,out]err#GError structure for error reporting, or NULL to disable error reporting.
Returns:
The newly-allocated path to real file on success, NULL otherwise.
Note:
Originally taken from gedit's source code.

Definition at line 650 of file f_basic.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines