Details
-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
Operating System: ReactOS
Platform: x86 Hardware
Description
Created an attachment (id=5593)
modified files base/shell/cmd
I wanted to prevent FILE IO and keeping batch files locked during execution.
Also when goto or internal calls are being used, currently a new filehandle gets opened in order to keep track of the position it is executing
I changed the way batch files are read and keep track of its position by reading the full batch file into memory and from that point only use memory instead of file IO.
During execution of a batch file, the file is now no longer accessed or locked
Downside it costs you some extra memory, advantage no locked files and less FILE IO.
Changes:
batch.h:
removed HBatchFile handle and added some mem vars
batch.c:
- added functions:
ClearBatch: remove some redundant code in ExitBatch and Batch for freeing mem
BatchFile2Mem : load the batchfile into memory
BatchGetString: Same as FileGetString, but now using the mem vars in the bc structure. - changed functions:
ExitBatch: now uses ClearBatch for freeing memory
Batch: determine is same filename is used as current (goto or internal call)
Uses ClearBatch to free the bc memory (same as ExitBatch)
Add logic to copy mem vars to new bc structure if filename is the same
If different filename is used, open file, load into mem, close file
ReadBatchLine: replaced FileGetString with BatchGetString
goto.c:
in function cmd_goto, changed the SetFilePointer code and replaced the FileGetString with BatchGetString
Attached are the modified files (from version 3.12)