Changeset 9e0b65484828b2b33db73d5324959df28b8d120d
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r577194b
|
r9e0b654
|
|
| 35 | 35 | #include "version.h" |
| 36 | 36 | |
| | 37 | #include "../common/file.h" |
| | 38 | |
| 37 | 39 | #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 | | } |
| 77 | 40 | |
| 78 | 41 | void show_about(void) |
-
|
rfb15df6
|
r9e0b654
|
|
| 541 | 541 | for source in [ |
| 542 | 542 | 'catdup.c', |
| | 543 | 'file.c', |
| 543 | 544 | ]: |
| 544 | 545 | gladish.source.append(os.path.join("common", source)) |