| 10 | | int InfoAddIntEntry(struct KeFsEntry* dir, char* name, int* value) |
| | 10 | int InfoReadInt(int* position, struct IcFsEntry* iEnt, char* data, DWORD size) |
| | 11 | { |
| | 12 | int copied; |
| | 13 | |
| | 14 | copied=MIN(size-*position, sizeof(int)-*position); |
| | 15 | |
| | 16 | memcpy(data, iEnt->iVal+*position, copied); |
| | 17 | |
| | 18 | *position+=copied; |
| | 19 | |
| | 20 | return copied; |
| | 21 | } |
| | 22 | |
| | 23 | int InfoReadStr(int* position, struct IcFsEntry* iEnt, char* data, DWORD size) |
| | 24 | { |
| | 25 | int copied; |
| | 26 | |
| | 27 | copied=MIN(size-*position, strlen(iEnt->sVal)-*position); |
| | 28 | |
| | 29 | memcpy(data, iEnt->sVal+*position, copied); |
| | 30 | |
| | 31 | *position+=copied; |
| | 32 | |
| | 33 | return copied; |
| | 34 | } |
| | 35 | |
| | 36 | int InfoReadArray(int* position, struct IcFsEntry* iEnt, char* data, DWORD size) |
| | 37 | { |
| | 38 | int copied; |
| | 39 | |
| | 40 | copied=MIN(size-*position, iEnt->size-*position); |
| | 41 | |
| | 42 | memcpy(data, iEnt->csVal+*position, copied); |
| | 43 | |
| | 44 | *position+=copied; |
| | 45 | |
| | 46 | return copied; |
| | 47 | } |
| | 48 | |
| | 49 | int IcRead(int* position, struct IcFsEntry* iEnt, char* data, DWORD size) |
| | 50 | { |
| | 51 | switch (iEnt->type) |
| | 52 | { |
| | 53 | case ICFS_TYPE_INT: |
| | 54 | return InfoReadInt(position, iEnt, data, size); |
| | 55 | |
| | 56 | case ICFS_TYPE_STR: |
| | 57 | return InfoReadStr(position, iEnt, data, size); |
| | 58 | |
| | 59 | case ICFS_TYPE_BYTE: |
| | 60 | return InfoReadArray(position, iEnt, data, size); |
| | 61 | |
| | 62 | default: |
| | 63 | KePrint("TODO: %d\n", iEnt->type); |
| | 64 | } |
| | 65 | |
| | 66 | return -EINVAL; |
| | 67 | } |
| | 68 | |
| | 69 | SYMBOL_EXPORT(IcRead); |
| | 70 | |
| | 71 | int IcWriteInt(int* position, struct IcFsEntry* iEnt, char* data, DWORD size) |
| | 72 | { |
| | 73 | int copied; |
| | 74 | |
| | 75 | copied=MIN(size-*position, sizeof(int)-*position); |
| | 76 | |
| | 77 | memcpy(iEnt->iVal+*position, data, copied); |
| | 78 | |
| | 79 | *position+=copied; |
| | 80 | |
| | 81 | return copied; |
| | 82 | } |
| | 83 | |
| | 84 | int IcWrite(int* position, struct IcFsEntry* iEnt, char* data, DWORD size) |
| | 85 | { |
| | 86 | switch (iEnt->type) |
| | 87 | { |
| | 88 | case ICFS_TYPE_INT: |
| | 89 | return IcWriteInt(position, iEnt, data, size); |
| | 90 | |
| | 91 | default: |
| | 92 | KePrint("TODO: %d\n", iEnt->type); |
| | 93 | } |
| | 94 | |
| | 95 | return -EINVAL; |
| | 96 | } |
| | 97 | |
| | 98 | SYMBOL_EXPORT(IcWrite); |
| | 99 | |
| | 100 | int IcFsAddIntEntry(struct KeFsEntry* fsRoot, struct KeFsEntry* dir, char* name, int* value) |
| 45 | | return 0; |
| 46 | | } |
| 47 | | |
| 48 | | struct KeFsEntry* InfoCreateDir(struct KeFsEntry* dir, char* name) |
| 49 | | { |
| 50 | | if (!dir) |
| 51 | | dir=&root; |
| | 140 | return newEnt; |
| | 141 | } |
| | 142 | |
| | 143 | int IcFsAddSoftLink(struct KeFsEntry* fsRoot, struct KeFsEntry* dir, char* name, int (*followLink)(char* buffer, int size)) |
| | 144 | { |
| | 145 | struct KeFsEntry* entry; |
| | 146 | |
| | 147 | if (!dir) |
| | 148 | dir=&fsRoot; |
| | 149 | |
| | 150 | entry=KeFsAddEntry(&dir->dir, name); |
| | 151 | |
| | 152 | entry->type &= ~VFS_ATTR_FILE; |
| | 153 | entry->type |= VFS_ATTR_SOFTLINK; |
| | 154 | |
| | 155 | entry->followLink=followLink; |
| | 156 | |
| | 157 | return 0; |
| | 158 | } |
| | 159 | |
| | 160 | int InfoAddStrEntry(struct KeFsEntry* dir, char* name, char* str) |
| | 161 | { |
| | 162 | IcFsAddStrEntry(&root, dir, name, str); |
| | 163 | return 0; |
| | 164 | } |
| | 165 | |
| | 166 | struct KeFsEntry* IcFsCreateDir(struct KeFsEntry* fsRoot, struct KeFsEntry* dir, char* name) |
| | 167 | { |
| | 168 | if (!dir) |
| | 169 | dir=fsRoot; |