| 1 | #cxx . . $ `<file>/dwsys/FileInMemory.h`/ifndef _FileInMemory_h_ |
| 2 | #define _FileInMemory_h_cxx . . $ `dwsys/FileInMemory.h:2:9`! |
| 3 | /* FileInMemory.h |
| 4 | * |
| 5 | * Copyright (C) 2011-2020 David Weenink, 2015,2018,2024,2025 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "Collection.h"cxx . . $ `<file>/sys/Collection.h`/ |
| 22 | #include "Strings_.h"cxx . . $ `<file>/sys/Strings_.h`/ |
| 23 | |
| 24 | #include "FileInMemory_def.h"cxx . . $ `<file>/dwsys/FileInMemory_def.h`/ |
| 25 | |
| 26 | Collection_definecxx . . $ constFileInMemorySet# (FileInMemorySet, SortedSetOfStringOf, FileInMemory) { |
| 27 | void v1_infocxx . . $ structFileInMemorySet#v1_info(49f6e7a06ebc5aa8). () |
| 28 | override; |
| 29 | }; |
| 30 | |
| 31 | autoFileInMemorycxx . . $ autoFileInMemory# FileInMemory_createcxx . . $ FileInMemory_create(7415c8b2fe7aa976). (MelderFilecxx . . $ MelderFile# file); |
| 32 | |
| 33 | /* |
| 34 | If the FileInMemory is created from static data we do not need to copy the data into the object but only |
| 35 | create a link to the data. This implies that the data cannot be deleted if the FileInMemory object gets |
| 36 | destroyed. However, if the FileInMemory object is copied, for example, then we also have to copy the data, |
| 37 | and the copied object has to become owner of these copied data. This is automatically guaranteed by our |
| 38 | implementation, because _dontOwnData is default-initialised as false. |
| 39 | Only if we create a FileInMemory object from data do we have to be explicit about ownership. |
| 40 | */ |
| 41 | autoFileInMemorycxx . . $ autoFileInMemory# FileInMemory_createWithDatacxx . . $ FileInMemory_createWithData(60c83988d9b3f0c4). (integercxx . . $ integer# numberOfBytes, uint8cxx . . $ uint8# *data, bool isStaticData, conststring32cxx . . $ conststring32# path); |
| 42 | |
| 43 | void FileInMemory_showAsCodecxx . . $ FileInMemory_showAsCode(5e2a89d09afc65c5). (FileInMemorycxx . . $ FileInMemory# me, conststring32cxx . . $ conststring32# name, integercxx . . $ integer# numberOfBytesPerLine); |
| 44 | |
| 45 | /* |
| 46 | File open and read emulations. |
| 47 | */ |
| 48 | |
| 49 | FileInMemorycxx . . $ FileInMemory# FileInMemory_fopencxx . . $ FileInMemory_fopen(c104e0235e2c5ecb). (FileInMemorycxx . . $ FileInMemory# me, const char *mode); |
| 50 | |
| 51 | FileInMemorycxx . . $ FileInMemory# FileInMemorySet_fopencxx . . $ FileInMemorySet_fopen(3c6da2b95de6d644). (FileInMemorySetcxx . . $ FileInMemorySet# me, const char *fileName, const char *mode); |
| 52 | |
| 53 | void FileInMemory_rewindcxx . . $ FileInMemory_rewind(c687222f051c68f9). (FileInMemorycxx . . $ FileInMemory# stream); |
| 54 | |
| 55 | int FileInMemory_fclosecxx . . $ FileInMemory_fclose(18557d97a31d1c3b). (FileInMemorycxx . . $ FileInMemory# stream); |
| 56 | |
| 57 | int FileInMemory_feofcxx . . $ FileInMemory_feof(18557d97a31d1c3b). (FileInMemorycxx . . $ FileInMemory# stream); |
| 58 | |
| 59 | int FileInMemory_ferrorcxx . . $ FileInMemory_ferror(18557d97a31d1c3b). (FileInMemorycxx . . $ FileInMemory# stream); |
| 60 | |
| 61 | integercxx . . $ integer# FileInMemory_ftellcxx . . $ FileInMemory_ftell(9412ae11c8b0cba2). (FileInMemorycxx . . $ FileInMemory# stream); |
| 62 | |
| 63 | int FileInMemory_fseekcxx . . $ FileInMemory_fseek(5881e18e5fd4da4e). (FileInMemorycxx . . $ FileInMemory# stream, integercxx . . $ integer# offset, int origin); |
| 64 | |
| 65 | char *FileInMemory_fgetscxx . . $ FileInMemory_fgets(8f279ba863457a36). (char *str, int num, FileInMemorycxx . . $ FileInMemory# stream); |
| 66 | |
| 67 | size_t FileInMemory_freadcxx . . $ FileInMemory_fread(44d619d1f1a9ecd5). (void *ptr, size_t size, size_t count, FileInMemorycxx . . $ FileInMemory# stream); |
| 68 | |
| 69 | int FileInMemory_fgetccxx . . $ FileInMemory_fgetc(18557d97a31d1c3b). (FileInMemorycxx . . $ FileInMemory# stream); |
| 70 | |
| 71 | int FileInMemory_ungetccxx . . $ FileInMemory_ungetc(94f650da2a730dba). (int character, FileInMemorycxx . . $ FileInMemory# stream); |
| 72 | |
| 73 | int FileInMemorySet_statcxx . . $ FileInMemorySet_stat(6caf238ea904729b). (FileInMemorySetcxx . . $ FileInMemorySet# me, const char *path, struct statcxx . . $ stat# *buf); |
| 74 | |
| 75 | /* |
| 76 | FileInMemorySet bookkeeping. |
| 77 | */ |
| 78 | |
| 79 | autoFileInMemorySetcxx . . $ autoFileInMemorySet# FileInMemorySet_createFromDirectoryContentscxx . . $ FileInMemorySet_createFromDirectoryContents(85027ea05bdbded6). (conststring32cxx . . $ conststring32# dirpath, conststring32cxx . . $ conststring32# file); |
| 80 | |
| 81 | autoFileInMemorySetcxx . . $ autoFileInMemorySet# FilesInMemory_to_FileInMemorySetcxx . . $ FilesInMemory_to_FileInMemorySet(cf70a12f9fe83a9b). (OrderedOfcxx . . $ OrderedOf#<structFileInMemorycxx . . $ structFileInMemory#>& list); |
| 82 | |
| 83 | autoFileInMemorySetcxx . . $ autoFileInMemorySet# FileInMemorySet_extractFilescxx . . $ FileInMemorySet_extractFiles(87e7f4beab83ee8). (FileInMemorySetcxx . . $ FileInMemorySet# me, kMelder_stringcxx . . $ kMelder_string# which, conststring32cxx . . $ conststring32# criterion); |
| 84 | autoFileInMemorySetcxx . . $ autoFileInMemorySet# FileInMemorySet_removeFilescxx . . $ FileInMemorySet_removeFiles(87e7f4beab83ee8). (FileInMemorySetcxx . . $ FileInMemorySet# me, kMelder_stringcxx . . $ kMelder_string# which, conststring32cxx . . $ conststring32# criterion); |
| 85 | |
| 86 | /* Only creates references to files in memory. Once me is deleted, the references are not valid any more!! */ |
| 87 | autoFileInMemorySetcxx . . $ autoFileInMemorySet# FileInMemorySet_listFilescxx . . $ FileInMemorySet_listFiles(87e7f4beab83ee8). (FileInMemorySetcxx . . $ FileInMemorySet# me, kMelder_stringcxx . . $ kMelder_string# which, conststring32cxx . . $ conststring32# criterion); |
| 88 | |
| 89 | integercxx . . $ integer# FileInMemorySet_getTotalNumberOfBytescxx . . $ FileInMemorySet_getTotalNumberOfBytes(d8441fa5fc43bf15). (FileInMemorySetcxx . . $ FileInMemorySet# me); |
| 90 | |
| 91 | autoFileInMemorySetcxx . . $ autoFileInMemorySet# FileInMemorySets_mergecxx . . $ FileInMemorySets_merge(d38f3e65cf74c5e0). (OrderedOfcxx . . $ OrderedOf#<structFileInMemorySetcxx . . $ structFileInMemorySet#>& list); |
| 92 | |
| 93 | void FileInMemorySet_showAsCodecxx . . $ FileInMemorySet_showAsCode(b232b36280c8ff8b). (FileInMemorySetcxx . . $ FileInMemorySet# me, conststring32cxx . . $ conststring32# name, integercxx . . $ integer# numberOfBytesPerLine); |
| 94 | |
| 95 | void FileInMemorySet_showOneFileAsCodecxx . . $ FileInMemorySet_showOneFileAsCode(104e1285ef1e0561). (FileInMemorySetcxx . . $ FileInMemorySet# me, integercxx . . $ integer# index, conststring32cxx . . $ conststring32# name, integercxx . . $ integer# numberOfBytesPerLine); |
| 96 | |
| 97 | integercxx . . $ integer# FileInMemorySet_findNumberOfMatches_pathcxx . . $ FileInMemorySet_findNumberOfMatches_path(eee94907be8851d8). (FileInMemorySetcxx . . $ FileInMemorySet# me, kMelder_stringcxx . . $ kMelder_string# which, conststring32cxx . . $ conststring32# criterion); |
| 98 | |
| 99 | bool FileInMemorySet_hasDirectorycxx . . $ FileInMemorySet_hasDirectory(b7f359b7604acef8). (FileInMemorySetcxx . . $ FileInMemorySet# me, conststring32cxx . . $ conststring32# name); |
| 100 | |
| 101 | autoStringscxx . . $ autoStrings# FileInMemorySet_to_Strings_pathcxx . . $ FileInMemorySet_to_Strings_path(c4bd1dc74aee5855). (FileInMemorySetcxx . . $ FileInMemorySet# me); |
| 102 | |
| 103 | /* |
| 104 | Testing. |
| 105 | */ |
| 106 | void test_FileInMemory_iocxx . . $ test_FileInMemory_io(49f6e7a06ebc5aa8). (); |
| 107 | |
| 108 | |
| 109 | /* End of file FileInMemory.h */ |
| 110 | #endif |