From 1dd3b2c72486884276ff7c9ad5a3761a0277a4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 15 Sep 2008 15:03:05 +0000 Subject: [PATCH] * ISO-9660 did not like files with only a single character length. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27573 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/iso9660/iso9660.cpp | 80 +++++++++---------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp index cb986809f1..23f40dc6a5 100644 --- a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp +++ b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp @@ -826,52 +826,48 @@ InitNode(iso9660_inode* node, char* buffer, size_t* _bytesRead, // on joliet discs, buffer[0] can be 0 for Unicoded filenames, // so I've added a check here to test explicitely for // directories (which have length 1) - if (node->name_length == 1) { - // Take care of "." and "..", the first two dirents are - // these in iso. - if (buffer[0] == 0) { - node->name = strdup("."); - node->name_length = 1; - } else if (buffer[0] == 1) { - node->name = strdup(".."); - node->name_length = 2; + // Take care of "." and "..", the first two dirents are + // these in iso. + if (node->name_length == 1 && buffer[0] == 0) { + node->name = strdup("."); + node->name_length = 1; + } else if (node->name_length == 1 && buffer[0] == 1) { + node->name = strdup(".."); + node->name_length = 2; + } else if (jolietLevel > 0) { + // JOLIET extension: convert Unicode16 string to UTF8 + // Assume that the unicode->utf8 conversion produces 4 byte + // utf8 characters, and allocate that much space + node->name = (char*)malloc(node->name_length * 2 + 1); + if (node->name == NULL) + return B_NO_MEMORY; + + int32 sourceLength = node->name_length; + int32 destLength = node->name_length * 2; + + status_t status = unicode_to_utf8(buffer, &sourceLength, + node->name, &destLength); + if (status < B_OK) { + dprintf("iso9660: error converting unicode->utf8\n"); + return status; } + + node->name[destLength] = '\0'; + node->name_length = destLength; + + sanitize_iso_name(node, false); } else { - if (jolietLevel > 0) { - // JOLIET extension: convert Unicode16 string to UTF8 - // Assume that the unicode->utf8 conversion produces 4 byte - // utf8 characters, and allocate that much space - node->name = (char*)malloc(node->name_length * 2 + 1); - if (node->name == NULL) - return B_NO_MEMORY; + node->name = (char*)malloc(node->name_length + 1); + if (node->name == NULL) + return B_NO_MEMORY; - int32 sourceLength = node->name_length; - int32 destLength = node->name_length * 2; - - status_t status = unicode_to_utf8(buffer, &sourceLength, - node->name, &destLength); - if (status < B_OK) { - dprintf("iso9660: error converting unicode->utf8\n"); - return status; - } - - node->name[destLength] = '\0'; - node->name_length = destLength; - - sanitize_iso_name(node, false); - } else { - node->name = (char*)malloc(node->name_length + 1); - if (node->name == NULL) - return B_NO_MEMORY; - - // convert all characters to lower case - for (uint32 i = 0; i < node->name_length; i++) { - node->name[i] = tolower(buffer[i]); - } - node->name[node->name_length] = '\0'; - - sanitize_iso_name(node, true); + // convert all characters to lower case + for (uint32 i = 0; i < node->name_length; i++) { + node->name[i] = tolower(buffer[i]); } + node->name[node->name_length] = '\0'; + + sanitize_iso_name(node, true); } if (node->name == NULL) {