Changeset 12072
- Timestamp:
- Feb 26, 2007, 5:31:56 PM (19 years ago)
- Location:
- trunk/psLib/src/sys
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psSlurp.c
r11617 r12072 5 5 * @author Joshua Hoblitt, University of Hawaii 6 6 * 7 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-02- 03 05:54:08$7 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-02-27 03:31:56 $ 9 9 * 10 10 * Copyright 2006 University of Hawaii … … 17 17 #include <stdio.h> 18 18 #include <unistd.h> 19 #include <sys/types.h> 20 #include <sys/stat.h> 21 #include <fcntl.h> 19 22 20 23 #include "psType.h" 24 #include "psAssert.h" 21 25 #include "psError.h" 22 26 #include "psSlurp.h" … … 56 60 } 57 61 62 58 63 psString psSlurpFile(FILE *stream) 59 64 { 60 65 return psSlurpFD(fileno(stream)); 61 66 } 67 68 69 psString psSlurpFilename(const char *filename) 70 { 71 PS_ASSERT_PTR_NON_NULL(filename, NULL); 72 73 int fd = open(filename, O_RDONLY); 74 if (fd < 0) { 75 psError(PS_ERR_IO, true, "Failed to open specified file, %s\n", filename); 76 return NULL; 77 } 78 79 psString text = psSlurpFD(fd); 80 81 if (close(fd) != 0) { 82 psError(PS_ERR_IO, true, "Failed to close specified file, %s\n", filename); 83 psFree(text); 84 return NULL; 85 } 86 87 return text; 88 } -
trunk/psLib/src/sys/psSlurp.h
r11695 r12072 4 4 * @author Joshua Hoblitt, University of Hawaii 5 5 * 6 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-02- 08 01:59:47$6 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-02-27 03:31:56 $ 8 8 */ 9 9 … … 24 24 ); 25 25 26 // Read ("slurp") a file (specified by filename) 27 // and return a string containing the entire file. 28 psString psSlurpFilename(const char *filename // Filename 29 ); 30 26 31 /// @} 27 32 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
