Changeset 3e018e45 in mainline
- Timestamp:
- 2011-07-07T20:03:19Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- af4dec0
- Parents:
- 411e9ca
- Location:
- uspace/srv/fs/fat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_directory.c
r411e9ca r3e018e45 255 255 { 256 256 int rc; 257 int long_entry_count; 258 uint8_t checksum; 259 wchar_t wname[FAT_LFN_NAME_SIZE]; 260 size_t lfn_size, lfn_offset; 261 262 rc = str_to_wstr(wname, FAT_LFN_NAME_SIZE, name); 263 if (rc != EOK) 264 return rc; 265 if (fat_dentry_is_sfn(wname)) { 257 bool enable_lfn = true; /* We can use this variable to switch off LFN support */ 258 259 if (fat_valid_short_name(name)) { 266 260 /* NAME could be directly stored in dentry without creating LFN */ 267 261 fat_dentry_name_set(de, name); 268 269 262 if (fat_directory_is_sfn_exist(di, de)) 270 263 return EEXIST; … … 273 266 return rc; 274 267 rc = fat_directory_write_dentry(di, de); 275 if (rc != EOK) 276 return rc; 277 278 return EOK; 279 } 280 else 281 { 268 return rc; 269 } else if (enable_lfn && fat_valid_name(name)) { 282 270 /* We should create long entries to store name */ 283 lfn_size = wstr_length(wname); 271 int long_entry_count; 272 uint8_t checksum; 273 uint16_t wname[FAT_LFN_NAME_SIZE]; 274 size_t lfn_size, lfn_offset; 275 276 rc = str_to_utf16(wname, FAT_LFN_NAME_SIZE, name); 277 if (rc != EOK) 278 return rc; 279 280 lfn_size = utf16_length(wname); 284 281 long_entry_count = lfn_size / FAT_LFN_ENTRY_SIZE; 285 282 if (lfn_size % FAT_LFN_ENTRY_SIZE) … … 291 288 292 289 /* Write Short entry */ 293 rc = fat_directory_create_sfn(di, de, wname);290 rc = fat_directory_create_sfn(di, de, name); 294 291 if (rc != EOK) 295 292 return rc; … … 322 319 323 320 rc = fat_directory_seek(di, start_pos+long_entry_count); 324 if (rc != EOK)325 return rc;326 return EOK; 327 }328 } 329 330 int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const wchar_t *wname)321 return rc; 322 } 323 324 return ENOTSUP; 325 } 326 327 int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const char *lname) 331 328 { 332 329 char name[FAT_NAME_LEN+1]; … … 337 334 memset(number, FAT_PAD, FAT_NAME_LEN); 338 335 339 size_t name_len = wstr_size(wname);340 wchar_t *pdot = wstr_rchr(wname, '.');336 size_t name_len = str_size(lname); 337 char *pdot = str_rchr(lname, '.'); 341 338 ext[FAT_EXT_LEN] = '\0'; 342 339 if (pdot) { 343 340 pdot++; 344 wstr_to_ascii(ext, pdot, FAT_EXT_LEN, FAT_SFN_CHAR);345 name_len = (pdot - wname - 1);341 str_to_ascii(ext, pdot, FAT_EXT_LEN, FAT_SFN_CHAR); 342 name_len = (pdot - lname - 1); 346 343 } 347 344 if (name_len > FAT_NAME_LEN) 348 345 name_len = FAT_NAME_LEN; 349 wstr_to_ascii(name, wname, name_len, FAT_SFN_CHAR);346 str_to_ascii(name, lname, name_len, FAT_SFN_CHAR); 350 347 351 348 size_t idx; -
uspace/srv/fs/fat/fat_directory.h
r411e9ca r3e018e45 68 68 extern int fat_directory_lookup_free(fat_directory_t *di, size_t count); 69 69 extern int fat_directory_write_dentry(fat_directory_t *di, fat_dentry_t *de); 70 extern int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const wchar_t *wname);70 extern int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const char *lname); 71 71 extern int fat_directory_expand(fat_directory_t *di); 72 72
Note:
See TracChangeset
for help on using the changeset viewer.