- #endif
- break;
- case RESOURCE_IN_STAGING_FILE:
- case RESOURCE_IN_FILE_ON_DISK:
- /* The resource is in some file on the external filesystem and
- * needs to be read uncompressed */
- wimlib_assert(lte->file_on_disk != NULL);
- BUILD_BUG_ON(<e->file_on_disk != <e->staging_file_name);
- /* Use existing file pointer if available; otherwise open one
- * temporarily */
- if (lte->file_on_disk_fp) {
- fp = lte->file_on_disk_fp;
- } else {
- fp = fopen(lte->file_on_disk, "rb");
- if (!fp) {
- ERROR_WITH_ERRNO("Failed to open the file "
- "`%s'", lte->file_on_disk);
- ret = WIMLIB_ERR_OPEN;
- break;
- }
- }
- ret = read_uncompressed_resource(fp, offset, size, buf);
- if (fp != lte->file_on_disk_fp)
- fclose(fp);
- break;
-#if defined(__CYGWIN__) || defined(__WIN32__)
- case RESOURCE_WIN32:
- wimlib_assert(lte->file_on_disk_fp != NULL);
- ret = win32_read_file(lte->file_on_disk, lte->file_on_disk_fp,
- offset, size, buf);
- break;
-#endif
- case RESOURCE_IN_ATTACHED_BUFFER:
- /* The resource is directly attached uncompressed in an
- * in-memory buffer. */
- wimlib_assert(lte->attached_buffer != NULL);
- memcpy(buf, lte->attached_buffer + offset, size);
- break;
-#ifdef WITH_NTFS_3G
- case RESOURCE_IN_NTFS_VOLUME:
- wimlib_assert(lte->ntfs_loc != NULL);
- wimlib_assert(lte->attr != NULL);
- if (lte->ntfs_loc->is_reparse_point)
- offset += 8;
- if (ntfs_attr_pread(lte->attr, offset, size, buf) != size) {
- ERROR_WITH_ERRNO("Error reading NTFS attribute "
- "at `%s'",
- lte->ntfs_loc->path_utf8);
- ret = WIMLIB_ERR_NTFS_3G;
- }
- break;
-#endif
- default:
- wimlib_assert(0);
- ret = -1;
- break;