Changeset 4363
- Timestamp:
- 08/25/06 12:58:35 (2 years ago)
- Files:
-
- libwired/trunk/libwired/file/wi-file.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/file/wi-file.c
r4289 r4363 791 791 792 792 wi_string_t * wi_file_read_to_string(wi_file_t *file, wi_string_t *separator) { 793 wi_string_t *string ;793 wi_string_t *string, *totalstring = NULL; 794 794 uint32_t index, length; 795 795 796 796 _WI_FILE_ASSERT_OPEN(file); 797 797 798 798 while((string = wi_file_read(file, WI_FILE_BUFFER_SIZE))) { 799 length = wi_string_length(string); 799 if(!totalstring) 800 totalstring = wi_string_init(wi_string_alloc()); 801 800 802 index = wi_string_index_of_string(string, separator, 0); 801 803 802 804 if(index == WI_NOT_FOUND) { 803 if(length < WI_FILE_BUFFER_SIZE) 804 return string; 805 wi_string_append_string(totalstring, string); 805 806 } else { 807 length = wi_string_length(string); 808 806 809 wi_string_delete_characters_from_index(string, index); 807 810 wi_string_append_string(totalstring, string); 811 808 812 wi_file_seek(file, wi_file_offset(file) - length + index + 1); 809 813 810 return string;814 break; 811 815 } 812 816 } 813 817 814 return NULL;818 return wi_autorelease(totalstring); 815 819 } 816 820
