v1.0 Cleaned garbage from code

This commit is contained in:
Berserker 2019-05-25 17:33:08 +03:00
parent 4b1a3df792
commit 45d3b258b9
4 changed files with 4 additions and 62 deletions

View File

@ -56,7 +56,6 @@ begin
VfsBase.MapDir(RootDir, VfsUtils.MakePath([RootDir, 'Mods\Apache']), DONT_OVERWRITE_EXISTING); VfsBase.MapDir(RootDir, VfsUtils.MakePath([RootDir, 'Mods\Apache']), DONT_OVERWRITE_EXISTING);
VfsDebug.SetLoggingProc(LogSomething); VfsDebug.SetLoggingProc(LogSomething);
VfsControl.RunVfs(VfsBase.SORT_FIFO); VfsControl.RunVfs(VfsBase.SORT_FIFO);
//Windows.MessageBoxA(0, '', '', 0); FIXME DELETEME
end; end;
procedure TestIntegrated.TearDown; procedure TestIntegrated.TearDown;

View File

@ -9,7 +9,7 @@ unit VfsControl;
uses uses
Windows, SysUtils, Windows, SysUtils,
Utils, WinUtils, TypeWrappers, DataLib, Files, StrLib, Utils, WinUtils, TypeWrappers, DataLib, Files, StrLib,
VfsBase, VfsUtils, VfsHooks, VfsWatching, DlgMes, FilesEx {FIXME DELETEME}; VfsBase, VfsUtils, VfsHooks, VfsWatching;
type type
(* Import *) (* Import *)
@ -176,18 +176,4 @@ begin
SysUtils.FreeAndNil(ModList); SysUtils.FreeAndNil(ModList);
end; // .function MapModsFromList end; // .function MapModsFromList
var s: string;
begin
// MapModsFromList('D:\Heroes 3', 'D:\heroes 3\Mods', 'd:\heroes 3\mods\list.txt');
// RunVfs(SORT_FIFO);
// ReadFileContents('D:\heroes 3\data\s\__T.erm', s);
// s := copy(s, 1, 100);
// VarDump([s]);
// VfsBase.PauseVfs;
// VfsBase.RefreshVfs;
// VfsBase.RunVfs(SORT_FIFO);
// ReadFileContents('D:\heroes 3\data\s\__T.erm', s);
// s := copy(s, 1, 100);
// VarDump([s]);
// exit;
end. end.

View File

@ -11,8 +11,7 @@ uses
Utils, WinNative, Concur, Utils, WinNative, Concur,
StrLib, Alg, StrLib, Alg,
VfsBase, VfsUtils, VfsPatching, VfsBase, VfsUtils, VfsPatching,
VfsDebug, VfsApiDigger, VfsOpenFiles, VfsDebug, VfsApiDigger, VfsOpenFiles;
{FIXME DELETEME} DlgMes;
(* Installs VFS hooks, if not already installed, in a thread-safe manner *) (* Installs VFS hooks, if not already installed, in a thread-safe manner *)

View File

@ -1,6 +1,6 @@
unit VfsWatching; unit VfsWatching;
(* (*
Description: provides means to watch for mapped directories changes and refresh VFS. Description: Provides means to watch for mapped directories changes and refresh VFS.
Works unreliably when trying to watch the whole logical drive. Works unreliably when trying to watch the whole logical drive.
*) *)
@ -10,7 +10,7 @@ unit VfsWatching;
uses uses
Windows, SysUtils, Math, Windows, SysUtils, Math,
Utils, Concur, WinUtils, StrLib, WinNative, Utils, Concur, WinUtils, StrLib, WinNative,
VfsBase, VfsUtils, DlgMes, Files {FIXME DELETEME}; VfsBase, VfsUtils;
(***) implementation (***) (***) implementation (***)
@ -216,22 +216,6 @@ begin
result := TDirChangesIterator.Create(DirPath); result := TDirChangesIterator.Create(DirPath);
end; end;
// function ReadNotification (const DirPath: WideString; var NotificationHandle: THandle): boolean;
// begin
// if IsValidHandle(NotificationHandle) then begin
// result := FindNextChangeNotification(NotificationHandle);
// if not result then begin
// Windows.FindCloseChangeNotification(NotificationHandle);
// NotificationHandle := INVALID_HANDLE_VALUE;
// end;
// end else begin
// NotificationHandle := FindFirstChangeNotificationW(PWideChar(DirPath), true, FILE_NOTIFY_CHANGE_FILE_NAME or FILE_NOTIFY_CHANGE_DIR_NAME or FILE_NOTIFY_CHANGE_ATTRIBUTES or
// FILE_NOTIFY_CHANGE_SIZE or FILE_NOTIFY_CHANGE_LAST_WRITE);
// result := IsValidHandle(NotificationHandle);
// end;
// end; // .function ReadNotification
function WatcherThreadProc (Arg: integer): integer; stdcall; function WatcherThreadProc (Arg: integer): integer; stdcall;
var var
IsEnd: LONGBOOL; IsEnd: LONGBOOL;
@ -244,8 +228,6 @@ var
DirChangesScanner: IDirChangesIterator; DirChangesScanner: IDirChangesIterator;
DirChange: TDirChange; DirChange: TDirChange;
filesize: integer;
begin begin
DirChangesScanner := nil; DirChangesScanner := nil;
// * * * * * // // * * * * * //
@ -265,7 +247,6 @@ begin
if NeedFullRescan and (PlannedRescanTime <= CurrentTime) then begin if NeedFullRescan and (PlannedRescanTime <= CurrentTime) then begin
VfsBase.RefreshVfs; VfsBase.RefreshVfs;
NeedFullRescan := false; NeedFullRescan := false;
VarDump(['Rescaned']);
end; end;
if DirChangesScanner = nil then begin if DirChangesScanner = nil then begin
@ -274,7 +255,6 @@ begin
// Failed to start watching directory // Failed to start watching directory
if not DirChangesScanner.IterNext(DirChange, WatcherStopEvent, Utils.IfThen(boolean(NeedFullRescan), integer(PlannedRescanTime - CurrentTime), integer(Windows.INFINITE))) then begin if not DirChangesScanner.IterNext(DirChange, WatcherStopEvent, Utils.IfThen(boolean(NeedFullRescan), integer(PlannedRescanTime - CurrentTime), integer(Windows.INFINITE))) then begin
VarDump([':(', AbsWatcherDir]);
// Force scanner recreation later // Force scanner recreation later
DirChangesScanner := nil; DirChangesScanner := nil;
@ -286,7 +266,6 @@ begin
end; end;
// Ok, got some signal // Ok, got some signal
end else begin end else begin
VarDump([ord(DirChange.Action), DirChange.FilePath]);
if DirChange.Action = NOTIFY_STOP_EVENT then begin if DirChange.Action = NOTIFY_STOP_EVENT then begin
IsEnd := true; IsEnd := true;
end else if DirChange.Action = NOTIFY_TIMEOUT then begin end else if DirChange.Action = NOTIFY_TIMEOUT then begin
@ -297,13 +276,6 @@ begin
end else if DirChange.Action = NOTIFY_FILE_MODIFIED then begin end else if DirChange.Action = NOTIFY_FILE_MODIFIED then begin
if not NeedFullRescan then begin if not NeedFullRescan then begin
VfsBase.RefreshMappedFile(DirChange.FilePath); VfsBase.RefreshMappedFile(DirChange.FilePath);
with VfsBase.GetThreadVfsDisabler do begin
EnableVfsForThread;
Files.GetFileSize(DirChange.FilePath, FileSize);
RestoreVfsForThread;
end;
VarDump([DirChange.FilePath, 'New size is', FileSize], 'Updated');
end; end;
LastChangeTime := WinUtils.GetMicroTime; LastChangeTime := WinUtils.GetMicroTime;
@ -344,18 +316,4 @@ begin
end; end;
end; // .function RunWatcher end; // .function RunWatcher
var
DirChange: TDirChange;
begin
// WatcherCritSection.Init;
// RunWatcher(GetCurrentDir + '\Tests\', 250);
// with ReadDirChanges('D:') do begin
// while IterNext(DirChange, 0) do begin
// VarDump([ord(DirChange.Action), DirChange.FilePath]);
// end;
// end;
// exit;
end. end.