Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
files.c File Reference
#include <config.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "common.h"
+ Include dependency graph for files.c:

Go to the source code of this file.

Functions

char * dgets (Dstring *dstr, FILE *in)
 
const char * file_basename (const char *filename)
 
const char * file_extension (const char *filename)
 
int file_readable (const char *filename)
 
int file_exists (const char *filename)
 

Function Documentation

char* dgets ( Dstring dstr,
FILE *  in 
)

Definition at line 26 of file files.c.

27 {
28  char buffer[256];
29 
30  dstr->length = 0;
31  if(feof(in))
32  return NULL;
33  while(fgets(buffer, 256, in) != NULL) {
34  int len = strlen(buffer);
35 
36  if(buffer[len-1] == '\n') {
37  dstring_append(dstr, buffer, len - 1);
38  break;
39  }
40  dstring_append(dstr, buffer, len);
41  }
42  if(dstr->data)
43  dstr->data[dstr->length] = 0;
44  return dstr->data;
45 }

+ Here is the caller graph for this function:

const char* file_basename ( const char *  filename)

Definition at line 49 of file files.c.

50 {
51  const char *ptr = strrchr(filename, '/');
52 
53  return (ptr ? ptr + 1 : filename);
54 }

+ Here is the caller graph for this function:

int file_exists ( const char *  filename)

Definition at line 72 of file files.c.

73 {
74  int status = (access(filename, F_OK) == 0);
75 
76  DEBUG((DBG_FILES, "file_exists(%s) -> %s\n",
77  filename, status ? "Yes" : "No"));
78  return status;
79 }

+ Here is the caller graph for this function:

const char* file_extension ( const char *  filename)

Definition at line 56 of file files.c.

57 {
58  const char *ptr = strchr(file_basename(filename), '.');
59 
60  return (ptr ? ptr + 1 : NULL);
61 }

+ Here is the caller graph for this function:

int file_readable ( const char *  filename)

Definition at line 63 of file files.c.

64 {
65  int status = (access(filename, R_OK) == 0);
66 
67  DEBUG((DBG_FILES, "file_redable(%s) -> %s\n",
68  filename, status ? "Yes" : "No"));
69  return status;
70 }