diff --git a/.gitignore b/.gitignore index ffc5727..0950413 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,3 @@ -Skip to content -Search or jump to… - -Pull requests -Issues -Marketplace -Explore - -@superolmo -2.9k -90.3k45.7kgithub/gitignore - Code Pull requests 107 Actions Projects 0 Security Insights -gitignore/VisualStudio.gitignore -@paulsmithkc paulsmithkc [VisualStudio] add Logs folder (#3143) -26c3d84 21 days ago -@shiftkey@arcresu@aroben@bbodenmiller@HassanHashemi@haacked@niik@AArnott@Zenuka@sayedihashimi@saschanaz@LunicLynx@OsirisTerje@sfhardman@jamiehumphries@richorama@RehanSaeed@marcrocny@matma@JFMG@jamesqo@elerch@cbadke@CoskunSunali@bdukes@anurse -354 lines (284 sloc) 5.91 KB - ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## diff --git a/Win32/Release/BigFiles.dll b/Win32/Release/BigFiles.dll deleted file mode 100644 index d2470e9..0000000 Binary files a/Win32/Release/BigFiles.dll and /dev/null differ diff --git a/Win32/Release/BigFiles.zip b/Win32/Release/BigFiles.zip index 9304476..ba413ee 100644 Binary files a/Win32/Release/BigFiles.zip and b/Win32/Release/BigFiles.zip differ diff --git a/src/BigFiles.cpp b/src/BigFiles.cpp index bcc9d77..e4e8488 100644 --- a/src/BigFiles.cpp +++ b/src/BigFiles.cpp @@ -23,32 +23,33 @@ extern void updateStatusBar3(FileTracker*); extern void closeBufferID3(int buffer_ID); extern int getBigFileRecordIndex3(int buffer_id); extern std::vector ftv; +extern Configuration* bigfiles_config; BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/) { - switch (reasonForCall) - { - case DLL_PROCESS_ATTACH: - pluginInit(hModule); - - break; + switch (reasonForCall) + { + case DLL_PROCESS_ATTACH: + pluginInit(hModule); + + break; - case DLL_PROCESS_DETACH: - pluginCleanUp(); - - break; + case DLL_PROCESS_DETACH: + pluginCleanUp(); - case DLL_THREAD_ATTACH: - - break; + break; - case DLL_THREAD_DETACH: - - break; - } + case DLL_THREAD_ATTACH: - return TRUE; + break; + + case DLL_THREAD_DETACH: + + break; + } + + return TRUE; } @@ -63,17 +64,29 @@ extern "C" __declspec(dllexport) const TCHAR * getName() return NPP_PLUGIN_NAME; } -extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *nbF) +extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int* nbF) { *nbF = nbFunc; return funcItem; } -extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode) +extern "C" __declspec(dllexport) void beNotified(SCNotification * notifyCode) { - switch (notifyCode->nmhdr.code) + int sci_bufferId = 0; + int record_index = 0; + sci_bufferId = notifyCode->nmhdr.idFrom; + + switch (notifyCode->nmhdr.code) { + case NPPN_FILEOPENED: + { + if (sci_bufferId == bigfiles_config->ConfFileBufferID) { + bigfiles_config->ConfFileBufferID = 0; + } + } + break; + case NPPN_SHUTDOWN: { commandMenuCleanUp(); @@ -85,21 +98,29 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode) commandRegToolbarIcons(); } break; - + case NPPN_FILECLOSED: { //When the FileClosed event happens, the Scintilla Buffer gets closed. // BigFiles needs to remove the reference to the buffer ID. - closeBufferID3((int)notifyCode->nmhdr.idFrom); - + closeBufferID3(sci_bufferId); } break; + case NPPN_FILESAVED: + { + if (sci_bufferId == bigfiles_config->ConfFileBufferID) { + msgBox_int(TEXT("Reloading Configuration"), sci_bufferId); + bigfiles_config->loadConfFile(); + } + } + break; + case NPPN_BUFFERACTIVATED: { // This happens when a Scintilla Buffer tab has been activated // Update the current buffer reference in the BigFiles structure - int record_index = getBigFileRecordIndex3((int)notifyCode->nmhdr.idFrom); + record_index = getBigFileRecordIndex3(sci_bufferId); if (record_index >= 0) updateStatusBar3(&ftv[record_index]); diff --git a/src/BigFiles.rc b/src/BigFiles.rc index efb67de..66e452c 100644 --- a/src/BigFiles.rc +++ b/src/BigFiles.rc @@ -2,7 +2,7 @@ // #pragma code_page(65001) -#include +#include "windows.h" #include "resource.h" ///////////////////////////////////////////////////////////////////////////// // English (United States) resources @@ -16,8 +16,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,1,2,0 - PRODUCTVERSION 0,1,2,0 + FILEVERSION 0,1,3,0 + PRODUCTVERSION 0,1,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -34,12 +34,12 @@ BEGIN BEGIN VALUE "CompanyName", "Claudio Olmi" VALUE "FileDescription", "BigFiles Plugin for Notepad++ to read very large files" - VALUE "FileVersion", "0.1.2.0" + VALUE "FileVersion", "0.1.3.0" VALUE "InternalName", "BigFiles.dll" VALUE "LegalCopyright", "Copyright 2020 by Claudio Olmi" VALUE "OriginalFilename", "BigFiles.dll" VALUE "ProductName", "BigFiles Plugin" - VALUE "ProductVersion", "0.1.2.0" + VALUE "ProductVersion", "0.1.3.0" END END BLOCK "VarFileInfo" @@ -107,6 +107,18 @@ BEGIN PUSHBUTTON "Cancel",IDC_BUTTON2,137,102,68,21 END +IDD_FORMVIEW1 DIALOGEX 0, 0, 185, 119 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x0 +BEGIN + LTEXT "Bytes per Page",IDC_STATIC,17,19,53,8 + EDITTEXT IDC_EDIT1,71,17,81,14,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_DLGMODALFRAME + CONTROL "Warn if running Notepad++ as Admin",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,39,141,15 + CONTROL "Warn of non-text file format",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,56,138,17 + PUSHBUTTON "Save",IDC_BUTTON1,19,86,61,19 + PUSHBUTTON "Cancel",IDC_BUTTON2,101,86,61,19 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -123,6 +135,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 147 END + + IDD_FORMVIEW1, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 178 + TOPMARGIN, 7 + BOTTOMMARGIN, 112 + END END #endif // APSTUDIO_INVOKED @@ -137,6 +157,11 @@ BEGIN 0 END +IDD_FORMVIEW1 AFX_DIALOG_LAYOUT +BEGIN + 0 +END + #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/Configuration.cpp b/src/Configuration.cpp index f8c2260..7b71985 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -5,7 +5,7 @@ Configuration::Configuration(NppData nppData) { this->_getPluginDirectory(nppData); //Load config file - this->loadConfFile(nppData); + this->loadConfFile(); } void Configuration::_getPluginDirectory(NppData nppData) { @@ -13,8 +13,8 @@ void Configuration::_getPluginDirectory(NppData nppData) { //TCHAR confFolder[1000]; TCHAR confDir[MAX_PATH]; ::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)confDir); - //wcsncpy(confFolder, confDir, MAX_PATH); - confFileNameFull = std::wstring(confDir) + L"\\bigfile.conf"; + confFilePath = std::wstring(confDir); + confFileNameFull = confFilePath + L"\\bigfile.conf"; } int Configuration::get_default_page_size_bytes() { @@ -23,6 +23,9 @@ int Configuration::get_default_page_size_bytes() { bool Configuration::get_default_isAdmin_warnings() { return this->default_isAdmin_warnings; }; +bool Configuration::get_default_BinaryFileType_warnings() { + return this->default_BinaryFileType_warnings; +}; /*********************************************************************************** Function was taken from Notepad++ plugin called Converter at @@ -41,23 +44,32 @@ void Configuration::_getCmdsFromConf(const TCHAR* confPath) if (*pFn && wcscmp(pFn, TEXT("BigFiles")) == 0) { int val = 0; - val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath); + + // Get page_size_bytes + val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right? if (val != 0) this->default_page_size_bytes = val; - val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath); + + // Get isAdmin_warnings + val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right? this->default_isAdmin_warnings = val != 0; + + // Get BinaryFileType_warnings + val = GetPrivateProfileInt(pFn, TEXT("BinaryFileType_warnings"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right? + this->default_BinaryFileType_warnings = val != 0; } else { ::MessageBox(NULL, TEXT("Configuration not found"), TEXT("BigFiles Plugin - Configuration::_getCmdsFromConf"), MB_OK); } } -void Configuration::loadConfFile(NppData nppData) +void Configuration::loadConfFile() { const char confContent[] = "\ [BigFiles]\n\ page_size_bytes=100000\n\ isAdmin_warnings=1\n\ +BinaryFileType_warnings=1\n\ \n"; //Get the fully qualified name of the config file, function saves it in confFileNameFull @@ -81,12 +93,13 @@ isAdmin_warnings=1\n\ //Get values from configuration file _getCmdsFromConf(confFileNameFull.c_str()); } + void Configuration::editConf(NppData nppData) { //IDM_FILE_OPEN if (!::PathFileExists(confFileNameFull.c_str())) { - loadConfFile(nppData); + loadConfFile(); } ::SendMessage(nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM)confFileNameFull.c_str()); } diff --git a/src/Configuration.h b/src/Configuration.h index 681a53a..bfb52ee 100644 --- a/src/Configuration.h +++ b/src/Configuration.h @@ -27,6 +27,8 @@ class Configuration int default_isAdmin_warnings = false; //If it is 1, it warns the user when Notepad++ is open in Admin mode. + int default_BinaryFileType_warnings = false; + private: // Function gets the directory path where the configuration folder is located // This function fills the global variable that is later used for loading and saving configurations @@ -37,14 +39,18 @@ class Configuration public: // Holds the fully qualified file name of the configuration file std::wstring confFileNameFull; + std::wstring confFilePath; + + int ConfFileBufferID = 0; // Constructor Configuration(NppData); - void loadConfFile(NppData nppData); + void loadConfFile(); void editConf(NppData nppData); // Getters int get_default_page_size_bytes(); bool get_default_isAdmin_warnings(); + bool get_default_BinaryFileType_warnings(); } ; \ No newline at end of file diff --git a/src/FileTracker.cpp b/src/FileTracker.cpp index 9396c82..826c8a9 100644 --- a/src/FileTracker.cpp +++ b/src/FileTracker.cpp @@ -10,7 +10,8 @@ FileTracker::FileTracker(HWND npp_handle, HWND scintilla_handle) { Function open the file in read-only and update the statistics in the file structure Returns */ -bool FileTracker::get_file_stats() { +bool FileTracker::get_file_stats(bool first_time_call = false) { + // Holding the first 4 character in the file for libmagic char binaryBuffer[5]; long double page_num_calc = 0.0; @@ -18,33 +19,38 @@ bool FileTracker::get_file_stats() { // - Get the file size to calculate the number of pages // Open stream in binary std::ifstream mybigfile_size(this->filename, std::ios::binary); - // Position stream pointer at the end + // First position stream pointer at the end mybigfile_size.seekg(0, mybigfile_size.end); - // Get current position value + // and get its position, this is the total file size this->file_size_bytes = mybigfile_size.tellg(); - this->file_size_left = this->file_size_bytes; - // Position stream pointer at the beginning + // NEXT STEP IS NOT NECESSARY + // Now position stream pointer at the beginning mybigfile_size.seekg(0, mybigfile_size.beg); //Compute number of pages based on page size page_num_calc = (long double)this->file_size_bytes / (long double)this->page_size_bytes; this->page_num_max = (int)std::floorl(page_num_calc) + 1; - // Get first 20 bytes of file - mybigfile_size.read(this->binarySignature, 20); + if (first_time_call) { + + this->file_size_left = this->file_size_bytes; + + // Get first MAX_SIGNATURE_BYTES bytes of file + mybigfile_size.read(this->binarySignature, MAX_SIGNATURE_BYTES); + + // find if the name of the file signature and get its name + file_type_structure* temp_file; + temp_file = libmagic_alike(this->binarySignature, MAX_SIGNATURE_BYTES); + + if (temp_file != NULL) { + this->binarySignatureName = &temp_file->name; + this->is_Binary = true; + } + else { + this->binarySignatureName = NULL; + this->is_Binary = false; + } - // find if the name of the file signature and get its name - file_type_structure* temp_file; - temp_file = libmagic_alike(this->binarySignature); - - if (temp_file != NULL) { - this->binarySignatureName = &temp_file->name; - this->is_Binary = true; - } - else { - this->binarySignatureName = NULL; - this->is_Binary = false; } - // Close binary stream mybigfile_size.close(); @@ -52,15 +58,27 @@ bool FileTracker::get_file_stats() { return TRUE; } +unsigned int FileTracker::find_EndOfLine(const std::string data) { + unsigned int charNum; + char newLine[] = {0x0A}; + charNum = data.find_last_of(newLine); + + return charNum; +} + // Function gets a new page_size_bytes of data and updates the current Scintilla tab // Inputs : integer with system of records index to update // Returns: VOID -void FileTracker::updateBuffer() +void FileTracker::updateBuffer(bool first_time_call) { wchar_t strMessage[1000]; size_t file_position; size_t cbDest = 1000 * sizeof(wchar_t); + if (first_time_call == false) { + this->get_file_stats(false); + } + // Open stream in Read-Only Mode and copy new data to string buffer std::ifstream myfile(this->filename, std::ios::in); std::string string_buffer(this->page_size_bytes, '\0'); @@ -113,14 +131,25 @@ void FileTracker::updateBuffer() } else { + wchar_t strMessage[1000]; + unsigned int charNum = find_EndOfLine(string_buffer); + //unsigned int leftOverChars = 0; + //StringCbPrintfW(strMessage, 1000, TEXT("Last Line Feed found at character number:%d"), charNum); + //::MessageBox(NULL, strMessage, TEXT("Debug"), MB_OK); + //string_buffer.assign(string_buffer, charNum); + //leftOverChars = string_buffer.length - charNum; + //this->file_size_left += leftOverChars; + //string_buffer[charNum] = { 0x00 }; ::SendMessage(this->scintilla_handle, SCI_SETTEXT, 0, (LPARAM)pst); } } -// Function open the filename specified by wchar_t filename_temp[500] -// Inputs : VOID -// Returns: VOID -void FileTracker::openBigFile(wchar_t filename_temp[], Configuration& bigfiles_config) +/* +Function open the filename +Inputs : filename specified by wchar_t filename_temp[500] +Returns: VOID +*/ +void FileTracker::openBigFile(const wchar_t filename_temp[], Configuration& bigfiles_config) { //Copy the filename from filename_temp to system of records new index @@ -141,8 +170,8 @@ void FileTracker::openBigFile(wchar_t filename_temp[], Configuration& bigfiles_c // Set stream position to beginning 0 this->sp = 0; - // Get file statistics - this->get_file_stats(); + // Get file statistics - First Time Call + this->get_file_stats(true); } @@ -227,3 +256,4 @@ bool FileTracker::move_to_end() { return false; } }; + diff --git a/src/FileTracker.h b/src/FileTracker.h index 13cc5fa..5dbd5e0 100644 --- a/src/FileTracker.h +++ b/src/FileTracker.h @@ -22,12 +22,16 @@ Used for: */ #include +#define MAX_SIGNATURE_BYTES 10 + #include "libmagic_alike.h" class FileTracker { public: - bool get_file_stats(); + bool get_file_stats(bool first_time_call); + + // File properties wchar_t filename[500]; size_t filename_size = 500 * sizeof(wchar_t); @@ -43,7 +47,7 @@ class FileTracker { wchar_t filetype_name[20]; // Binary Signature - char binarySignature[5]; + char binarySignature[MAX_SIGNATURE_BYTES]; std::wstring *binarySignatureName; // Handles to communicate with Scintilla and NPP @@ -54,7 +58,7 @@ class FileTracker { FileTracker(HWND npp_handle, HWND scintilla_handle); // Open a Bigfile - void openBigFile(wchar_t[], Configuration&); + void openBigFile(const wchar_t[], Configuration&); // Move backward in the file (page--) bool move_backward(); @@ -65,6 +69,7 @@ class FileTracker { // Move to the start of the file bool move_to_start(); - void updateBuffer(); + void updateBuffer(bool first_time_call); + unsigned int find_EndOfLine(const std::string data); }; \ No newline at end of file diff --git a/src/PluginDefinition.cpp b/src/PluginDefinition.cpp index a5ed81b..af4d369 100644 --- a/src/PluginDefinition.cpp +++ b/src/PluginDefinition.cpp @@ -54,25 +54,30 @@ extern void move_to_start3(); extern void move_to_end3(); extern void move_forward3(); extern void move_backward3(); -extern void openBigFile3(); +extern void openBigFile3(const wchar_t filename[]); +extern void openBigFileDlg3(); extern void cleanupv3(); extern int ft_length; extern std::vector ftv; +HANDLE global_npp_handle; + //--------- START LOADING AND UNLOADING FUNCTIONS ---------------- // // Initialize your plugin data here // It will be called while plugin loading -void pluginInit(HANDLE global_npp_handle /*hModule*/) +void pluginInit(HANDLE g_npp_handle /*hModule*/) { - left_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)global_npp_handle, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); - right_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)global_npp_handle,MAKEINTRESOURCE(IDB_BITMAP2), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); - open_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)global_npp_handle, MAKEINTRESOURCE(IDB_BITMAP3), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); - start_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)global_npp_handle, MAKEINTRESOURCE(IDB_BITMAP5), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); - end_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)global_npp_handle, MAKEINTRESOURCE(IDB_BITMAP4), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); + global_npp_handle = g_npp_handle; + + left_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_npp_handle, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); + right_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_npp_handle,MAKEINTRESOURCE(IDB_BITMAP2), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); + open_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_npp_handle, MAKEINTRESOURCE(IDB_BITMAP3), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); + start_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_npp_handle, MAKEINTRESOURCE(IDB_BITMAP5), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); + end_icon->hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_npp_handle, MAKEINTRESOURCE(IDB_BITMAP4), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); //This section below can go to command menu init and get modified by configuration file AltLeftKey->_isAlt = true; @@ -106,8 +111,8 @@ void pluginInit(HANDLE global_npp_handle /*hModule*/) void pluginCleanUp() { // This happens when Notepad++ close the main window - delete AltLeftKey, AltRightKey, AltUpKey, AltDownKey; - delete [] &bigfile; + delete bigfiles_config; + cleanupv3(); } // @@ -127,7 +132,7 @@ void commandMenuInit() // bool check0nInit // optional. Make this menu item be checked visually // ); - setCommand(0, TEXT("Open BigFile"), openBigFile3, NULL, false); + setCommand(0, TEXT("Open BigFile"), openBigFileDlg3, NULL, false); setCommand(1, TEXT("Backward"), move_backward3, AltLeftKey, false); setCommand(2, TEXT("Forward"), move_forward3, AltRightKey, false); @@ -148,12 +153,41 @@ void commandMenuInit() //Get configuration bigfiles_config = new Configuration(nppData); + +} + +INT_PTR CALLBACK ConfigurationDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) +{ + switch (Message) + { + case WM_INITDIALOG: + + return TRUE; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + EndDialog(hwnd, IDOK); + break; + case IDCANCEL: + EndDialog(hwnd, IDCANCEL); + break; + } + break; + default: + return FALSE; + } + return TRUE; } // Function tells NOTEPAD++ to open the configuration file void openConfigFile() { + // TODO: Add a save function hook to know when Notepad++ saves the file? + // or just implement my own dialog box. ::SendMessage(nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM) bigfiles_config->confFileNameFull.c_str()); + Sleep(500); + bigfiles_config->ConfFileBufferID = (int)::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0); } // @@ -165,6 +199,7 @@ void commandMenuCleanUp() // Don't forget to deallocate your shortcut here delete AltLeftKey, AltRightKey, AltDownKey, AltUpKey; + delete left_icon, right_icon, open_icon, start_icon, end_icon; } // Register Toolbar Icons diff --git a/src/PluginDefinition.h b/src/PluginDefinition.h index 8abeb40..7df1b90 100644 --- a/src/PluginDefinition.h +++ b/src/PluginDefinition.h @@ -79,7 +79,7 @@ Function used: //#define BIGFILES_DEBUG - +#define DEBUG_LIBMAGIC #define PLUGIN_NAME "BigFiles" #define PLUGIN_NUMBER_OF_FUNCTIONS 7 @@ -98,6 +98,7 @@ const int nbFunc = PLUGIN_NUMBER_OF_FUNCTIONS; //-------- END SETTINGS -------- +INT_PTR CALLBACK ConfigurationDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); //--------- START LOADING AND UNLOADING FUNCTIONS ---------------- // diff --git a/src/RCa16544 b/src/RCa16544 new file mode 100644 index 0000000..87aeea7 Binary files /dev/null and b/src/RCa16544 differ diff --git a/src/Support.cpp b/src/Support.cpp index d0ad0d9..043e908 100644 --- a/src/Support.cpp +++ b/src/Support.cpp @@ -8,6 +8,14 @@ void msgBox_int(wchar_t* str, int v) { ::MessageBox(NULL, strMessage, TEXT("BigFiles Plugin - Debug"), MB_OK); } +void msgBox_hex(wchar_t* str, char v) { + wchar_t strMessage[500]; + size_t cbDest = 500 * sizeof(wchar_t); + StringCchPrintfW(strMessage, cbDest, TEXT("%s: %02X"), str, v); + //wsprintf(strMessage, TEXT("%s: %d"), str, v); + ::MessageBox(NULL, strMessage, TEXT("BigFiles Plugin - Debug"), MB_OK); +} + void msgBox(wchar_t* str) { wchar_t strMessage[500]; size_t cbDest = 500 * sizeof(wchar_t); diff --git a/src/Support.h b/src/Support.h index 8d6530d..84b6904 100644 --- a/src/Support.h +++ b/src/Support.h @@ -11,5 +11,6 @@ Used for: void msgBox(wchar_t*); void msgBox_int(wchar_t* str, int v); +void msgBox_hex(wchar_t* str, int v); diff --git a/src/libmagic_alike.cpp b/src/libmagic_alike.cpp index 083e1e8..863f3d5 100644 --- a/src/libmagic_alike.cpp +++ b/src/libmagic_alike.cpp @@ -141,7 +141,7 @@ void libmagic_initialize() { Returns: pointer to file structure of the corresponding file type -1 if not found */ -file_type_structure* libmagic_alike(char binBuf[20]) +file_type_structure* libmagic_alike(char binBuf[], unsigned int signature_max_size) { char pattern[20]; wchar_t strMessage[1500]; @@ -156,10 +156,11 @@ file_type_structure* libmagic_alike(char binBuf[20]) // Go througt the whole file type array for (int j = 0; j < file_types_length; j++) { -#ifdef BIGFILES_DEBUG //Copy string pattern to local char array memcpy(pattern, file_types[j].str_pattern.c_str(), file_types[j].pattern_length); +#ifdef DEBUG_LIBMAGIC + // Write pattern against file header wsprintf(strMessage, TEXT("%d - Type: %ls\n"), j, file_types[j].name.c_str() ); strM.append(strMessage); @@ -171,7 +172,9 @@ file_type_structure* libmagic_alike(char binBuf[20]) //binBuf[0], binBuf[1], binBuf[2], binBuf[3], binBuf[4] ::MessageBox(NULL, strM.c_str(), TEXT("BigFiles Plugin - Debug"), MB_OK); strM.clear(); + #endif + // Compare patterns if (memcmp(binBuf, file_types[j].str_pattern.c_str(), file_types[j].pattern_length) == 0) { diff --git a/src/libmagic_alike.h b/src/libmagic_alike.h index 32230cd..86af108 100644 --- a/src/libmagic_alike.h +++ b/src/libmagic_alike.h @@ -21,6 +21,6 @@ void libmagic_initialize(); Function check the type of a file based on the first 4 binary char, similar to what libmagic does. TODO: Is it worth to import the libmagic library or better to keep it simple and just add simple checking? */ -file_type_structure* libmagic_alike(char binBuf[20]); +file_type_structure* libmagic_alike(char binBuf[], unsigned int); //file_type_structure* libmagic_alike2(char binBuf[], unsigned int binBuf_length); diff --git a/src/resource.h b/src/resource.h index 761eb31..4a57f5f 100644 --- a/src/resource.h +++ b/src/resource.h @@ -71,7 +71,6 @@ #define LWS_TRANSPARENT 0x0001 #define LVS_REPORT 0x0001 #define TVS_HASBUTTONS 0x0001 -#define TVS_EX_NOSINGLECOLLAPSE 0x0001 #define TCS_SCROLLOPPOSITE 0x0001 #define ACS_CENTER 0x0001 #define MCS_DAYSTATE 0x0001 @@ -90,8 +89,6 @@ #define SUBLANG_ARMENIAN_ARMENIA 0x01 #define SUBLANG_ASSAMESE_INDIA 0x01 #define SUBLANG_AZERI_LATIN 0x01 -#define SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN 0x01 -#define SUBLANG_BANGLA_INDIA 0x01 #define SUBLANG_BASHKIR_RUSSIA 0x01 #define SUBLANG_BASQUE_BASQUE 0x01 #define SUBLANG_BELARUSIAN_BELARUS 0x01 @@ -99,8 +96,6 @@ #define SUBLANG_BRETON_FRANCE 0x01 #define SUBLANG_BULGARIAN_BULGARIA 0x01 #define SUBLANG_CATALAN_CATALAN 0x01 -#define SUBLANG_CENTRAL_KURDISH_IRAQ 0x01 -#define SUBLANG_CHEROKEE_CHEROKEE 0x01 #define SUBLANG_CHINESE_TRADITIONAL 0x01 #define SUBLANG_CORSICAN_FRANCE 0x01 #define SUBLANG_CZECH_CZECH_REPUBLIC 0x01 @@ -123,7 +118,6 @@ #define SUBLANG_GREENLANDIC_GREENLAND 0x01 #define SUBLANG_GUJARATI_INDIA 0x01 #define SUBLANG_HAUSA_NIGERIA_LATIN 0x01 -#define SUBLANG_HAWAIIAN_US 0x01 #define SUBLANG_HEBREW_ISRAEL 0x01 #define SUBLANG_HINDI_INDIA 0x01 #define SUBLANG_HUNGARIAN_HUNGARY 0x01 @@ -157,7 +151,6 @@ #define SUBLANG_NEPALI_NEPAL 0x01 #define SUBLANG_NORWEGIAN_BOKMAL 0x01 #define SUBLANG_OCCITAN_FRANCE 0x01 -#define SUBLANG_ODIA_INDIA 0x01 #define SUBLANG_ORIYA_INDIA 0x01 #define SUBLANG_PASHTO_AFGHANISTAN 0x01 #define SUBLANG_PERSIAN_IRAN 0x01 @@ -168,7 +161,6 @@ #define SUBLANG_ROMANIAN_ROMANIA 0x01 #define SUBLANG_ROMANSH_SWITZERLAND 0x01 #define SUBLANG_RUSSIAN_RUSSIA 0x01 -#define SUBLANG_SAKHA_RUSSIA 0x01 #define SUBLANG_SAMI_NORTHERN_NORWAY 0x01 #define SUBLANG_SANSKRIT_INDIA 0x01 #define SUBLANG_SCOTTISH_GAELIC 0x01 @@ -188,7 +180,6 @@ #define SUBLANG_TELUGU_INDIA 0x01 #define SUBLANG_THAI_THAILAND 0x01 #define SUBLANG_TIBETAN_PRC 0x01 -#define SUBLANG_TIGRINYA_ETHIOPIA 0x01 #define SUBLANG_TSWANA_SOUTH_AFRICA 0x01 #define SUBLANG_TURKISH_TURKEY 0x01 #define SUBLANG_TURKMEN_TURKMENISTAN 0x01 @@ -212,11 +203,20 @@ #define SORT_GERMAN_PHONE_BOOK 0x1 #define SORT_HUNGARIAN_TECHNICAL 0x1 #define SORT_GEORGIAN_MODERN 0x1 +#define __drv_typeCond 1 #define VS_VERSION_INFO 1 #define VFFF_ISSHAREDFILE 0x0001 #define VFF_CURNEDEST 0x0001 #define VIFF_FORCEINSTALL 0x0001 -#define WINAPI_FAMILY_PC_APP 2 +#define TVS_EX_NOSINGLECOLLAPSE 0x0001 +#define SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN 0x01 +#define SUBLANG_BANGLA_INDIA 0x01 +#define SUBLANG_CENTRAL_KURDISH_IRAQ 0x01 +#define SUBLANG_CHEROKEE_CHEROKEE 0x01 +#define SUBLANG_HAWAIIAN_US 0x01 +#define SUBLANG_ODIA_INDIA 0x01 +#define SUBLANG_SAKHA_RUSSIA 0x01 +#define SUBLANG_TIGRINYA_ETHIOPIA 0x01 #define SW_SHOWMINIMIZED 2 #define SHOW_ICONWINDOW 2 #define SW_OTHERZOOM 2 @@ -263,14 +263,11 @@ #define SUBLANG_SYS_DEFAULT 0x02 #define SUBLANG_ARABIC_IRAQ 0x02 #define SUBLANG_AZERI_CYRILLIC 0x02 -#define SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC 0x02 -#define SUBLANG_BANGLA_BANGLADESH 0x02 #define SUBLANG_BENGALI_BANGLADESH 0x02 #define SUBLANG_CHINESE_SIMPLIFIED 0x02 #define SUBLANG_DUTCH_BELGIAN 0x02 #define SUBLANG_ENGLISH_UK 0x02 #define SUBLANG_FRENCH_BELGIAN 0x02 -#define SUBLANG_FULAH_SENEGAL 0x02 #define SUBLANG_GERMAN_SWISS 0x02 #define SUBLANG_INUKTITUT_CANADA_LATIN 0x02 #define SUBLANG_IRISH_IRELAND 0x02 @@ -283,8 +280,6 @@ #define SUBLANG_NEPALI_INDIA 0x02 #define SUBLANG_NORWEGIAN_NYNORSK 0x02 #define SUBLANG_PORTUGUESE 0x02 -#define SUBLANG_PULAR_SENEGAL 0x02 -#define SUBLANG_PUNJABI_PAKISTAN 0x02 #define SUBLANG_QUECHUA_ECUADOR 0x02 #define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02 #define SUBLANG_SERBIAN_LATIN 0x02 @@ -293,17 +288,23 @@ #define SUBLANG_SPANISH_MEXICAN 0x02 #define SUBLANG_SWEDISH_FINLAND 0x02 #define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02 -#define SUBLANG_TAMIL_SRI_LANKA 0x02 #define SUBLANG_TIGRIGNA_ERITREA 0x02 -#define SUBLANG_TIGRINYA_ERITREA 0x02 -#define SUBLANG_TSWANA_BOTSWANA 0x02 #define SUBLANG_URDU_INDIA 0x02 #define SUBLANG_UZBEK_CYRILLIC 0x02 -#define SUBLANG_VALENCIAN_VALENCIA 0x02 #define SORT_CHINESE_PRC 0x2 +#define __drv_typeBitset 2 #define VFF_FILEINUSE 0x0002 #define VIFF_DONTDELETEOLD 0x0002 -#define WINAPI_FAMILY_PHONE_APP 3 +#define WINAPI_FAMILY_PC_APP 2 +#define SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC 0x02 +#define SUBLANG_BANGLA_BANGLADESH 0x02 +#define SUBLANG_FULAH_SENEGAL 0x02 +#define SUBLANG_PULAR_SENEGAL 0x02 +#define SUBLANG_PUNJABI_PAKISTAN 0x02 +#define SUBLANG_TAMIL_SRI_LANKA 0x02 +#define SUBLANG_TIGRINYA_ERITREA 0x02 +#define SUBLANG_TSWANA_BOTSWANA 0x02 +#define SUBLANG_VALENCIAN_VALENCIA 0x02 #define SW_SHOWMAXIMIZED 3 #define SW_MAXIMIZE 3 #define SHOW_FULLSCREEN 3 @@ -323,7 +324,6 @@ #define LVS_LIST 0x0003 #define LVS_TYPEMASK 0x0003 #define LANG_CATALAN 0x03 -#define LANG_VALENCIAN 0x03 #define SUBLANG_CUSTOM_DEFAULT 0x03 #define SUBLANG_ARABIC_EGYPT 0x03 #define SUBLANG_CHINESE_HONGKONG 0x03 @@ -336,7 +336,8 @@ #define SUBLANG_SPANISH_MODERN 0x03 #define SORT_CHINESE_BOPOMOFO 0x3 #define __drv_typeExpr 3 -#define WINAPI_FAMILY_SYSTEM 4 +#define WINAPI_FAMILY_PHONE_APP 3 +#define LANG_VALENCIAN 0x03 #define SW_SHOWNOACTIVATE 4 #define SHOW_OPENNOACTIVATE 4 #define SW_OTHERUNZOOM 4 @@ -381,11 +382,11 @@ #define SUBLANG_GERMAN_LUXEMBOURG 0x04 #define SUBLANG_SAMI_LULE_NORWAY 0x04 #define SUBLANG_SPANISH_GUATEMALA 0x04 -#define SUBLANG_TAMAZIGHT_MOROCCO_TIFINAGH 0x04 #define SORT_JAPANESE_RADICALSTROKE 0x4 #define SORT_CHINESE_RADICALSTROKE 0x4 #define VFF_BUFFTOOSMALL 0x0004 -#define WINAPI_FAMILY_SERVER 5 +#define WINAPI_FAMILY_SYSTEM 4 +#define SUBLANG_TAMAZIGHT_MOROCCO_TIFINAGH 0x04 #define SW_SHOW 5 #define VK_XBUTTON1 0x05 #define WM_SIZE 0x0005 @@ -404,6 +405,7 @@ #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05 #define SUBLANG_SAMI_LULE_SWEDEN 0x05 #define SUBLANG_SPANISH_COSTA_RICA 0x05 +#define WINAPI_FAMILY_SERVER 5 #define SW_MINIMIZE 6 #define VK_XBUTTON2 0x06 #define WM_ACTIVATE 0x0006 @@ -721,15 +723,15 @@ #define LANG_UZBEK 0x43 #define WM_COMMNOTIFY 0x0044 #define LANG_TATAR 0x44 -#define LANG_BANGLA 0x45 #define LANG_BENGALI 0x45 +#define LANG_BANGLA 0x45 #define WM_WINDOWPOSCHANGING 0x0046 #define LANG_PUNJABI 0x46 #define WM_WINDOWPOSCHANGED 0x0047 #define LANG_GUJARATI 0x47 #define WM_POWER 0x0048 -#define LANG_ODIA 0x48 #define LANG_ORIYA 0x48 +#define LANG_ODIA 0x48 #define LANG_TAMIL 0x49 #define WM_COPYDATA 0x004A #define LANG_TELUGU 0x4a @@ -773,10 +775,10 @@ #define LANG_FRISIAN 0x62 #define VK_NUMPAD3 0x63 #define LANG_PASHTO 0x63 -#define WINAPI_FAMILY_DESKTOP_APP 100 #define VK_NUMPAD4 0x64 #define LANG_FILIPINO 0x64 #define VS_USER_DEFINED 100 +#define WINAPI_FAMILY_DESKTOP_APP 100 #define VK_NUMPAD5 0x65 #define LANG_DIVEHI 0x65 #define IDI_ICON1 101 @@ -784,6 +786,7 @@ #define IDD_FORMVIEW 101 #define VK_NUMPAD6 0x66 #define IDI_ARROW_RIGHT_ICON 102 +#define IDD_FORMVIEW1 102 #define VK_NUMPAD7 0x67 #define LANG_FULAH 0x67 #define LANG_PULAR 0x67 @@ -871,25 +874,25 @@ #define LANG_ALSATIAN 0x84 #define VK_F22 0x85 #define WM_NCPAINT 0x0085 -#define LANG_SAKHA 0x85 #define LANG_YAKUT 0x85 +#define LANG_SAKHA 0x85 #define VK_F23 0x86 #define WM_NCACTIVATE 0x0086 #define LANG_KICHE 0x86 #define VK_F24 0x87 #define WM_GETDLGCODE 0x0087 #define LANG_KINYARWANDA 0x87 -#define VK_NAVIGATION_VIEW 0x88 #define WM_SYNCPAINT 0x0088 #define LANG_WOLOF 0x88 +#define VK_NAVIGATION_VIEW 0x88 #define VK_NAVIGATION_MENU 0x89 #define VK_NAVIGATION_UP 0x8A #define VK_NAVIGATION_DOWN 0x8B -#define VK_NAVIGATION_LEFT 0x8C #define LANG_DARI 0x8c +#define VK_NAVIGATION_LEFT 0x8C #define VK_NAVIGATION_RIGHT 0x8D -#define VK_NAVIGATION_ACCEPT 0x8E #define CF_DSPENHMETAFILE 0x008E +#define VK_NAVIGATION_ACCEPT 0x8E #define VK_NAVIGATION_CANCEL 0x8F #define VK_NUMLOCK 0x90 #define VK_SCROLL 0x91 @@ -963,49 +966,49 @@ #define EM_LINELENGTH 0x00C1 #define EM_REPLACESEL 0x00C2 #define VK_GAMEPAD_A 0xC3 -#define VK_GAMEPAD_B 0xC4 #define EM_GETLINE 0x00C4 -#define VK_GAMEPAD_X 0xC5 +#define VK_GAMEPAD_B 0xC4 #define EM_LIMITTEXT 0x00C5 -#define VK_GAMEPAD_Y 0xC6 +#define VK_GAMEPAD_X 0xC5 #define EM_CANUNDO 0x00C6 -#define VK_GAMEPAD_RIGHT_SHOULDER 0xC7 +#define VK_GAMEPAD_Y 0xC6 #define EM_UNDO 0x00C7 -#define VK_GAMEPAD_LEFT_SHOULDER 0xC8 +#define VK_GAMEPAD_RIGHT_SHOULDER 0xC7 #define EM_FMTLINES 0x00C8 -#define VK_GAMEPAD_LEFT_TRIGGER 0xC9 +#define VK_GAMEPAD_LEFT_SHOULDER 0xC8 #define EM_LINEFROMCHAR 0x00C9 +#define VK_GAMEPAD_LEFT_TRIGGER 0xC9 #define VK_GAMEPAD_RIGHT_TRIGGER 0xCA -#define VK_GAMEPAD_DPAD_UP 0xCB #define EM_SETTABSTOPS 0x00CB -#define VK_GAMEPAD_DPAD_DOWN 0xCC +#define VK_GAMEPAD_DPAD_UP 0xCB #define EM_SETPASSWORDCHAR 0x00CC -#define VK_GAMEPAD_DPAD_LEFT 0xCD +#define VK_GAMEPAD_DPAD_DOWN 0xCC #define EM_EMPTYUNDOBUFFER 0x00CD -#define VK_GAMEPAD_DPAD_RIGHT 0xCE +#define VK_GAMEPAD_DPAD_LEFT 0xCD #define EM_GETFIRSTVISIBLELINE 0x00CE -#define VK_GAMEPAD_MENU 0xCF +#define VK_GAMEPAD_DPAD_RIGHT 0xCE #define EM_SETREADONLY 0x00CF -#define VK_GAMEPAD_VIEW 0xD0 +#define VK_GAMEPAD_MENU 0xCF #define EM_SETWORDBREAKPROC 0x00D0 -#define VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON 0xD1 +#define VK_GAMEPAD_VIEW 0xD0 #define EM_GETWORDBREAKPROC 0x00D1 -#define VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON 0xD2 +#define VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON 0xD1 #define EM_GETPASSWORDCHAR 0x00D2 -#define VK_GAMEPAD_LEFT_THUMBSTICK_UP 0xD3 +#define VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON 0xD2 #define EM_SETMARGINS 0x00D3 -#define VK_GAMEPAD_LEFT_THUMBSTICK_DOWN 0xD4 +#define VK_GAMEPAD_LEFT_THUMBSTICK_UP 0xD3 #define EM_GETMARGINS 0x00D4 -#define VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT 0xD5 +#define VK_GAMEPAD_LEFT_THUMBSTICK_DOWN 0xD4 #define EM_GETLIMITTEXT 0x00D5 -#define VK_GAMEPAD_LEFT_THUMBSTICK_LEFT 0xD6 +#define VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT 0xD5 #define EM_POSFROMCHAR 0x00D6 -#define VK_GAMEPAD_RIGHT_THUMBSTICK_UP 0xD7 +#define VK_GAMEPAD_LEFT_THUMBSTICK_LEFT 0xD6 #define EM_CHARFROMPOS 0x00D7 -#define VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN 0xD8 +#define VK_GAMEPAD_RIGHT_THUMBSTICK_UP 0xD7 #define EM_SETIMESTATUS 0x00D8 -#define VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT 0xD9 +#define VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN 0xD8 #define EM_GETIMESTATUS 0x00D9 +#define VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT 0xD9 #define VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT 0xDA #define EM_ENABLEFEATURE 0x00DA #define VK_OEM_4 0xDB @@ -1251,6 +1254,7 @@ #define IDC_CHECK1 1001 #define IDC_BUTTON1 1002 #define IDC_BUTTON2 1003 +#define IDC_CHECK2 1004 #define CF_GDIOBJLAST 0x03FF #define _WIN32_WINNT_NT4 0x0400 #define _WIN32_IE_IE40 0x0400 @@ -1435,13 +1439,14 @@ #define FILEOPENORD 1536 #define _WIN32_WINNT_WIN7 0x0601 #define _WIN32_IE_IE60SP1 0x0601 +#define _WIN32_WINNT 0x0601 #define MULTIFILEOPENORD 1537 -#define _WIN32_WINNT_WIN8 0x0602 #define _WIN32_IE_WS03 0x0602 #define PRINTDLGORD 1538 -#define _WIN32_WINNT_WINBLUE 0x0603 +#define _WIN32_WINNT_WIN8 0x0602 #define _WIN32_IE_IE60SP2 0x0603 #define PRNSETUPDLGORD 1539 +#define _WIN32_WINNT_WINBLUE 0x0603 #define FINDDLGORD 1540 #define REPLACEDLGORD 1541 #define FONTDLGORD 1542 @@ -1459,6 +1464,7 @@ #define IDC_MANAGE_LINK 1592 #define _WIN32_IE_IE70 0x0700 #define _WIN32_IE_IE80 0x0800 +#define _WIN32_IE 0x0800 #define CS_SAVEBITS 0x0800 #define HDS_NOSIZING 0x0800 #define TBSTYLE_FLAT 0x0800 @@ -1598,9 +1604,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 113 +#define _APS_NEXT_RESOURCE_VALUE 114 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_CONTROL_VALUE 1005 #define _APS_NEXT_SYMED_VALUE 103 #endif #endif diff --git a/src/v3.cpp b/src/v3.cpp index 4068367..2207d88 100644 --- a/src/v3.cpp +++ b/src/v3.cpp @@ -8,7 +8,8 @@ void move_to_start3(); void move_to_end3(); void move_forward3(); void move_backward3(); -void openBigFile3(); +void openBigFile3(const wchar_t filename[]); +void openBigFileDlg3(); void cleanupv3(); std::vector ftv; @@ -20,10 +21,11 @@ extern Configuration* bigfiles_config; extern wchar_t filename_temp[500]; void cleanupv3() { - delete[] & ftv; + // Delete will be used in the future when I move from static to dynamic allocation of ftv vector + //delete[] & ftv; } -void openBigFile3() { +void openBigFileDlg3() { //If system of records holds 9 records, do not open another one // TODO: Is the limit set to 9 records meaningless? if (ft_length == 9) { @@ -41,28 +43,33 @@ void openBigFile3() { // Get the file name from the Windows Dialog Box if (getFileName()) { - // Get the current scintilla - int which = -1; - ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which); - if (which == -1) - return; - HWND curScintilla = (which == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle; + openBigFile3(filename_temp); + } +} + +void openBigFile3(const wchar_t filename[]) { + + // Get the current scintilla + int which = -1; + ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which); + if (which == -1) + return; + HWND curScintilla = (which == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle; - FileTracker* ft1 = new FileTracker(nppData._nppHandle, curScintilla); - ft1->openBigFile(filename_temp, *bigfiles_config); - ft1->updateBuffer(); + FileTracker* ft1 = new FileTracker(nppData._nppHandle, curScintilla); + ft1->openBigFile(filename, *bigfiles_config); + ft1->updateBuffer(true); - updateStatusBar3(ft1); + updateStatusBar3(ft1); - ftv.push_back(*ft1); + ftv.push_back(*ft1); - // check file type - if (ft1->binarySignatureName != NULL) { - ::MessageBox(NULL, ft1->binarySignatureName->c_str(), TEXT(PLUGIN_DEFAULT_MESSAGEBOX_TITLE), MB_OK); - } - else { - // i don't recognise the file - } + // check file type + if (ft1->binarySignatureName != NULL) { + ::MessageBox(NULL, ft1->binarySignatureName->c_str(), TEXT(PLUGIN_DEFAULT_MESSAGEBOX_TITLE), MB_OK); + } + else { + // i don't recognise the file } } @@ -71,7 +78,7 @@ void move_backward3() { int i = getBigFileRecordIndex3((int)::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0)); if (i != -1) { if (ftv[i].move_backward()) { - ftv[i].updateBuffer(); + ftv[i].updateBuffer(false); updateStatusBar3(&ftv[i]); } else { @@ -86,7 +93,7 @@ void move_forward3() { int i = getBigFileRecordIndex3((int)::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0)); if (i != -1) { if (ftv[i].move_forward()) { - ftv[i].updateBuffer(); + ftv[i].updateBuffer(false); updateStatusBar3(&ftv[i]); } else { @@ -102,7 +109,7 @@ void move_to_start3() { int i = getBigFileRecordIndex3((int)::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0)); if (i != -1) { if (ftv[i].move_to_start()) { - ftv[i].updateBuffer(); + ftv[i].updateBuffer(false); updateStatusBar3(&ftv[i]); } // Move Scintilla to first character @@ -115,7 +122,7 @@ void move_to_end3() { int i = getBigFileRecordIndex3((int)::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0)); if (i != -1) { if (ftv[i].move_to_end()) { - ftv[i].updateBuffer(); + ftv[i].updateBuffer(false); updateStatusBar3(&ftv[i]); } else { diff --git a/vs.proj/BigFiles.exp b/vs.proj/BigFiles.exp index 68091c1..911868e 100644 Binary files a/vs.proj/BigFiles.exp and b/vs.proj/BigFiles.exp differ diff --git a/vs.proj/BigFiles.lib b/vs.proj/BigFiles.lib index b6a8155..8de6b13 100644 Binary files a/vs.proj/BigFiles.lib and b/vs.proj/BigFiles.lib differ diff --git a/vs.proj/BigFiles.vcxproj b/vs.proj/BigFiles.vcxproj index c97ff4a..542725f 100644 --- a/vs.proj/BigFiles.vcxproj +++ b/vs.proj/BigFiles.vcxproj @@ -108,6 +108,7 @@ true + true false @@ -148,6 +149,7 @@ true Speed MultiThreadedDebug + true Windows diff --git a/x64/Release/BigFiles.dll b/x64/Release/BigFiles.dll index 1326be3..78929ec 100644 Binary files a/x64/Release/BigFiles.dll and b/x64/Release/BigFiles.dll differ diff --git a/x64/Release/BigFiles.zip b/x64/Release/BigFiles.zip index cf12a0f..0946799 100644 Binary files a/x64/Release/BigFiles.zip and b/x64/Release/BigFiles.zip differ