Changeset 9e0b65484828b2b33db73d5324959df28b8d120d

Show
Ignore:
Timestamp:
11/28/10 12:26:36 (2 years ago)
Author:
Nikita Zlobin <cook60020tmp@…>
Children:
a5d878cdc4363738db31c771dace7c14c4c75d3b
Parents:
416c65254bc9ccc5cdc7d6a4b8d0550e4b2d9041
git-author:
Nikita Zlobin <cook60020tmp@mail.ru> / 2010-10-18T16:32:14Z+0600
git-committer:
Nikita Zlobin <cook60020tmp@mail.ru> / 2010-11-28T15:26:36Z+0500
Message:

Make file reading function common

Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • gui/about.c

    r577194b r9e0b654  
    3535#include "version.h" 
    3636 
     37#include "../common/file.h" 
     38 
    3739#define ABOUT_DIALOG_LOGO     "ladish-logo-128x128.png" 
    38  
    39 static char * read_file_contents(const char * filename) 
    40 { 
    41   int fd; 
    42   struct stat st; 
    43   char * buffer; 
    44  
    45   if (stat(filename, &st) != 0) 
    46   { 
    47     return NULL; 
    48   } 
    49  
    50   fd = open(filename, O_RDONLY); 
    51   if (fd == -1) 
    52   { 
    53     return NULL; 
    54   } 
    55  
    56   buffer = malloc(st.st_size + 1); 
    57   if (buffer == NULL) 
    58   { 
    59     close(fd); 
    60     return NULL; 
    61   } 
    62  
    63   if (read(fd, buffer, (size_t)st.st_size) != (ssize_t)st.st_size) 
    64   { 
    65     free(buffer); 
    66     buffer = NULL; 
    67   } 
    68   else 
    69   { 
    70     buffer[st.st_size] = 0; 
    71   } 
    72  
    73   close(fd); 
    74  
    75   return buffer; 
    76 } 
    7740 
    7841void show_about(void) 
  • wscript

    rfb15df6 r9e0b654  
    541541        for source in [ 
    542542            'catdup.c', 
     543            'file.c', 
    543544            ]: 
    544545            gladish.source.append(os.path.join("common", source))