mirror of
https://github.com/Ragora/T2-BoL.git
synced 2026-03-02 20:10:21 +00:00
Brought up to date with the newest T2BoL I've located
This commit is contained in:
parent
8c96cba3e1
commit
accd31895e
287 changed files with 108557 additions and 107608 deletions
80
scripts/modscripts/shared/fileProcessing.cs
Normal file
80
scripts/modscripts/shared/fileProcessing.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// -----------------------------------------------------
|
||||
// fileProcessing.cs
|
||||
// Basic file functions
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
// -----------------------------------------------------
|
||||
function getFileBuffer(%file)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileBuffer);
|
||||
FileBuffer.openForRead(%file);
|
||||
|
||||
while (!FileBuffer.isEOF())
|
||||
%buffer = %buffer @ FileBuffer.readLine() @ "\n";
|
||||
FileBuffer.detach();
|
||||
return %buffer; //Long string. >.>
|
||||
}
|
||||
|
||||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
||||
for (%i = 0; %i < %line; %i++)
|
||||
%line = FileLine.readLine();
|
||||
FileLine.detach();
|
||||
return %line;
|
||||
}
|
||||
|
||||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
||||
for (%i = 0; %i < %line; %i++)
|
||||
%line = FileLine.readLine();
|
||||
FileLine.detach();
|
||||
return %line;
|
||||
}
|
||||
|
||||
// Returns an unsorted list of the contents of %dir (including folders)
|
||||
function getDirectory(%dir)
|
||||
{
|
||||
%array = Array.create();
|
||||
|
||||
%fileCount = 0;
|
||||
for( %file = findFirstFile( %dir @ "*.*" ); %file !$= ""; %file = findNextFile( %dir @ "*.*" ) )
|
||||
{
|
||||
%file = strReplace(%file, %socket.request, "");
|
||||
if (strStr(%file, "/") != -1)
|
||||
{
|
||||
%dir = getSubStr(%file, 0, strStr(%file, "/")) @ "/";
|
||||
if (!%dirAdded[%dir])
|
||||
{
|
||||
%data = %data @ "<a href=\"" @ strReplace(%dir, " ","%20") @ "\">" @ %dir @ "</a><br>\n";
|
||||
%dirAdded[%dir] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
%data = %data @ "<a href=\"" @ strReplace(%file, " ", "%20") @ "\">" @ %file @ "</a><br>\n";
|
||||
}
|
||||
return %array;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Bound Functions
|
||||
// -----------------------------------------------------
|
||||
function fileObject::Detach(%this) //Detaches fileObject from file & deletes
|
||||
{
|
||||
%this.close();
|
||||
%this.delete();
|
||||
return %this;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue