[misc] add NTFS compression support

* Only as a cheat mode (Alt-N)
* Also fixes inconsistent MBR partition numbering
* Also update a comment in vhd.c about callback progress (thanks to Erwan)
This commit is contained in:
Pete Batard 2014-01-31 02:51:28 +00:00
parent 189e96762b
commit f424229e0f
11 changed files with 58 additions and 27 deletions

View file

@ -614,7 +614,7 @@ int GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSyst
AnalyzeMBR(hPhysical);
for (i=0; i<DriveLayout->PartitionCount; i++) {
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
uprintf("Partition %d:\n", DriveLayout->PartitionEntry[i].PartitionNumber);
uprintf("Partition %d:\n", i+1);
part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType;
uprintf(" Type: %s (0x%02x)\r\n Size: %s (%lld bytes)\r\n Start Sector: %d, Boot: %s, Recognized: %s\n",
((part_type==0x07)&&(FileSystemName[0]!=0))?FileSystemName:GetPartitionType(part_type), part_type,

View file

@ -56,7 +56,7 @@ static int task_number = 0;
extern const int nb_steps[FS_MAX];
extern uint32_t dur_mins, dur_secs;
static int fs_index = 0;
BOOL force_large_fat32 = FALSE;
BOOL force_large_fat32 = FALSE, enable_ntfs_compression = FALSE;
static BOOL WritePBR(HANDLE hLogicalDrive);
/*
@ -662,6 +662,7 @@ static BOOL FormatDrive(DWORD DriveIndex)
{
BOOL r = FALSE;
PF_DECL(FormatEx);
PF_DECL(EnableVolumeCompression);
char FSType[32];
char *locale, *VolumeName = NULL;
WCHAR* wVolumeName = NULL;
@ -678,18 +679,22 @@ static BOOL FormatDrive(DWORD DriveIndex)
} else {
PrintStatus(0, TRUE, MSG_222, FSType);
}
VolumeName = GetLogicalName(DriveIndex, FALSE, TRUE);
VolumeName = GetLogicalName(DriveIndex, TRUE, TRUE);
wVolumeName = utf8_to_wchar(VolumeName);
if (wVolumeName == NULL) {
uprintf("Could not read volume name\n");
goto out;
}
// Hey, nice consistency here, Microsoft! - FormatEx() fails if wVolumeName has
// a trailing backslash, but EnableCompression() fails without...
wVolumeName[wcslen(wVolumeName)-1] = 0; // Remove trailing backslash
// LoadLibrary("fmifs.dll") appears to changes the locale, which can lead to
// problems with tolower(). Make sure we restore the locale. For more details,
// see http://comments.gmane.org/gmane.comp.gnu.mingw.user/39300
locale = setlocale(LC_ALL, NULL);
PF_INIT_OR_OUT(FormatEx, fmifs);
PF_INIT(EnableVolumeCompression, fmifs);
setlocale(LC_ALL, locale);
GetWindowTextW(hFileSystem, wFSType, ARRAYSIZE(wFSType));
@ -714,8 +719,19 @@ static BOOL FormatDrive(DWORD DriveIndex)
format_percent = 0.0f;
task_number = 0;
fs_index = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
pfFormatEx(wVolumeName, SelectedDrive.Geometry.MediaType, wFSType, wLabel,
IsChecked(IDC_QUICKFORMAT), ulClusterSize, FormatExCallback);
if ((fs == FS_NTFS) && (enable_ntfs_compression) && (pfEnableVolumeCompression != NULL)) {
wVolumeName[wcslen(wVolumeName)] = '\\'; // Add trailing backslash back again
if (pfEnableVolumeCompression(wVolumeName, FPF_COMPRESSED)) {
uprintf("Enabled NTFS compression\n");
} else {
uprintf("Could not enable NTFS compression: %s\n", WindowsErrorString());
}
}
if (!IS_ERROR(FormatStatus)) {
uprintf("Format completed.\n");
r = TRUE;

View file

@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility
* Formatting function calls
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop
* Copyright © 2011-2013 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2014 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -97,12 +97,12 @@ typedef LONG (WINAPI *Chkdsk_t)(
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa383357.aspx */
typedef enum {
FPF_COMPRESSED = 0x01
FPF_COMPRESSED = 0x01
} FILE_SYSTEM_PROP_FLAG;
typedef BOOLEAN (WINAPI* EnableVolumeCompression_t)(
WCHAR* DriveRoot,
ULONG CompressionFlags // FILE_SYSTEM_PROP_FLAG
WCHAR* DriveRoot,
ULONG CompressionFlags // FILE_SYSTEM_PROP_FLAG
);
/* Large FAT32 */

View file

@ -358,6 +358,7 @@ const loc_control_id control_id[] = {
LOC_CTRL(MSG_257),
LOC_CTRL(MSG_258),
LOC_CTRL(MSG_259),
LOC_CTRL(MSG_260),
LOC_CTRL(MSG_MAX),
LOC_CTRL(IDOK),
LOC_CTRL(IDCANCEL),

View file

@ -1,6 +1,6 @@
#!/bin/sh
echo This file recreates localization_data.c according resource.h
echo This file recreates localization_data.h according resource.h
echo
# check that sed is available

View file

@ -377,7 +377,8 @@
#define MSG_257 3257
#define MSG_258 3258
#define MSG_259 3259
#define MSG_MAX 3260
#define MSG_260 3260
#define MSG_MAX 3261
// Next default values for new objects
//

View file

@ -117,7 +117,7 @@ static BOOL log_displayed = FALSE;
static BOOL iso_provided = FALSE;
static BOOL user_notified = FALSE;
static BOOL relaunch = FALSE;
extern BOOL force_large_fat32, enable_joliet, enable_rockridge;
extern BOOL force_large_fat32, enable_joliet, enable_rockridge, enable_ntfs_compression;
static int selection_default;
static loc_cmd* selected_locale = NULL;
static UINT_PTR UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU;
@ -2479,6 +2479,12 @@ relaunch:
PrintStatus2000(lmprintf(MSG_256), detect_fakes);
continue;
}
// Alt N => Enable NTFS compression
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'N')) {
enable_ntfs_compression = !enable_ntfs_compression;
PrintStatus2000(lmprintf(MSG_260), enable_ntfs_compression);
continue;
}
// Alt-R => Remove all the registry keys created by Rufus
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'R')) {
PrintStatus(2000, FALSE, DeleteRegistryKey(REGKEY_HKCU, COMPANY_NAME "\\" APPLICATION_NAME)?MSG_248:MSG_249);

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 1.4.4.397"
CAPTION "Rufus 1.4.4.398"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -165,7 +165,7 @@ END
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
CAPTION "Rufus 1.4.4.397"
CAPTION "Rufus 1.4.4.398"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -427,8 +427,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,4,397
PRODUCTVERSION 1,4,4,397
FILEVERSION 1,4,4,398
PRODUCTVERSION 1,4,4,398
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -445,13 +445,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.4.397"
VALUE "FileVersion", "1.4.4.398"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.4.397"
VALUE "ProductVersion", "1.4.4.398"
END
END
BLOCK "VarFileInfo"

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Virtual Disk Handling functions
* Copyright © 2013 Pete Batard <pete@akeo.ie>
* Copyright © 2013-2014 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -96,7 +96,8 @@ BOOL WimExtractCheck(void)
// Extract a file from a WIM image using wimgapi.dll (Windows 7 or later)
// NB: Don't bother trying to get progress from a WIM callback - it doesn't work!
// NB: if you want progress from a WIM callback, you must run the WIM API call in its own thread
// (which we don't do here) as it won't work otherwise. Thanks go to Erwan for figuring this out!
static BOOL WimExtractFile_API(const char* image, int index, const char* src, const char* dst)
{
BOOL r = FALSE;