Leo<HTML>

File Klasse

JS - Referenz
JS Syntax
Ausgabe
Leohtml Klasse
File Klasse
    Konzept
    Interface
    Handhabung
Get_tmp_file Funktion
Line Klasse
Tag Klasse
Lexer Klasse
Rebuilt_file Funktion

Quellen von file.html:
  
     
 
<include file="top.lhhtml"> 
 
<lconf pos="/file" pagename="file"> 
 
 
<section link="/file/concept" local="concept"> 
 
<locale> 
  <locale language="de"> 
 
Für das Zugreifen auf Dateien ist diese Klasse zuständig. Die Klasse ist keinesfalls 
ein simples Interface zu einer Datei. Die Klasse wurde entwickelt um bei Bedarf 
entweder auf eine Datei zuzugreifen, oder eine Datei virtuell im Speicher zu 
simulieren.<br> 
<leohtml> nutzt diese Eigenschaft intensiv und muß daher keine temporären Dateien 
kreieren. Diese werden stattdessen in den Speicher geschrieben.<br> 
Also wundere dich nicht, und studieren diese Klasse intensiv. 
 
  </locale> 
  <locale language="en"> 
 
For accessing file this class can be used. This class is not a simple interface 
to a file. The class was developed for accessing a real file or simulating a file 
in the memory. <br> 
<leohtml> is massively using this feature and as the result of this it does not 
need temporary files.<br> 
So don't be supriced and study this class intensively. 
 
  </locale> 
</locale> 
 
</section> 
 
<!-- ***************************** --> 
 
<section link="/file/interface" local="interface"> 
 
<definition title-de="File Klassen definition" titl-en="File Class Definition"> 
<include file="file.def"> 
</definition> 
 
<!-- ***************************** --> 
 
<faq title-en="Overview" title-de="Überblick"> 
 
<locale> 
  <locale language="de"> 
 
Bei dieser Klasse besteht eine Datei immer aus zwei Teilen: aus der 
eigentlichen Datei und einem Zeiger auf diese Datei. Es kann immer 
nur eine Datei geben, was klar sein sollte, aber es können mehrere 
Zeiger auf eine Datei zeigen.<br> 
Die <code>File</code> Klasse ist eigentlich ein Zeiger auf eine Datei. 
Wird nun die <code>File</code> Klasse kopiert, so wird nicht die Datei 
kopiert sondern nur der Zeiger auf die Datei. Somit kann die <code>File</code> 
Klasse problemlos dazu eingesetzt werden um als Funktionsparameter übergeben zu werden. 
 
  </locale> 
  <locale language="en"> 
 
At this class a file consists of two parts: the real file and 
a pointer to the file. There can only exist one file but several pointers 
to the file.<br> 
The <code>File</code> class is a pointer to a file. 
If you copy the <code>File</code> class you do not copy the file, you will 
only copy the pointer to the file. Consequently you can use the <code>File</code> 
class as function parameter. 
 
  </locale> 
</locale> 
 
<p> 
 
<locale> 
  <locale language="de"> 
 
Die zweite Eigenschaft der <code>File</code> Klasse ist, das eine Datei 
nicht im Dateisystem existieren muß. Eine Datei kann auch einfach im Speicher 
erstellt werden. Dies ist ideal für temporäre Dateien.<br> 
Der Zugriff und auch die Erzeugung solcher virtuellen Dateien ist schneller 
als bei einer realen Datei. Der Vor- und Nachteil allerdings ist, dass eine 
solche Datei nur während der Ausführung von <leohtml> existiert. Dannach sind 
die Daten für immer verloren. 
 
  </locale> 
  <locale language="en"> 
 
The second feature of the <code>File</code> File class is the possibility 
to create virtual file, that does not exist in the file system, but is created 
in the memory. That's ideal for temporary files.<br> 
The access and the creation of temorary files is faster as at real files. 
But the disadvantage is that such a virtual file only exists during the 
execution of <leohtml>. When the compiler finished execution all datas are lost. 
 
  </locale> 
</locale> 
 
</p> 
 
  <faq title-de="Hinweis:" title-en="Hint:"> 
 
  <locale> 
    <locale language="de"> 
 
  Mit der <link path="/get_tmp_file"> können eindeutige Dateinamen angefordert 
  werden, die sich sehr gut für die erzeugung von temporären Dateien eignet. 
 
    </locale> 
    <locale language="en"> 
 
  The <link path="/get_tmp_file"> returns unique file names for temporary files. 
 
    </locale> 
  </locale> 
 
  </faq> 
 
</faq> 
 
 
<!-- ***************************** --> 
 
<faq title-de="Konstruktoren" title-en="Constructors"> 
 
<locale> 
  <locale language="de"> 
 
Es gibt 3 Konstruktoren: 
 
  </locale> 
  <locale language="en"> 
 
There are three Constructors: 
 
  </locale> 
</locale> 
 
<br><br> 
 
  <faq title="File()"> 
 
  <locale> 
    <locale language="de"> 
 
  Eine neue Instanz dieser Klasse wird erzeugt. Diese Klasse ist so lange ungültig, 
  bis mit <code>open()</code> eine Datei geöffnet wird, oder mit <code>reference()</code> 
  eine andere Klasse übernommen wird. 
 
    </locale> 
    <locale language="en"> 
 
  A new instance of this class will be created. This class will be invalid as long as 
  a file will be opend with the <code>open()</code> function, or a other file class 
  will be referenced by using the <code>reference()</code> function. 
 
    </locale> 
  </locale> 
 
  </faq> 
 
  <faq title="File( String name, String openmode, Bool nocreate = false, Bool realfile = true)"> 
 
  <locale> 
    <locale language="en"> 
 
  Open or create a file. The parameters are equal to the <code>open()</code> function. 
  There you will find their description too. 
 
    </locale> 
    <locale language="de"> 
 
  Öffnde oder keriere eine Datei. Die Parameter sind die gleichen, wie bei der <code>open()</code> 
  Funktion. Dort wirst du auch deren Beschreibung finden. 
 
    </locale> 
   </locale> 
 
  </faq> 
 
  <faq title="File( File other_file )"> 
 
  <locale> 
    <locale language="en"> 
 
  Copy the other <code>File</code> class. This means not copying the real file. 
  Only the poiter to the file dublicated. 
 
    </locale> 
    <locale language="de"> 
 
  Kopiere die andere <code>File</code> Klasse. Dies beudeted nicht, dass die reale Datei 
  kopiert wird. Nur der Zeiger auf die Datei wird kopiert. 
 
    </locale> 
  </locale> 
 
  </faq> 
 
 
</faq> 
 
<!-- ***************************** --> 
 
<faq title="Null open( String name, String openmode, nocreate = false, realfile = true )"> 
 
<lang en text="This function opens a file."> 
<lang de text="Mit dieser Funktion kann eine Datei geöffnet werden."> 
 
<br><br> 
 
  <faq title="String name"> 
 
    <lang de text="Der Name der Datei."> 
    <lang en text="The name of the file."> 
 
  </faq> 
 
  <faq title="String openmode"> 
 
    <locale> 
      <locale language="en"> 
 
     The openmode of the file. It's a character string. 
     These are the characters that can be used and it's meaning: 
 
       </locale> 
       <locale language="de"> 
 
     Die Zugriffsart mit der die Datei geöffnet werden sell. 
     Dies sind die Zeichen die verwendet werden können und deren Bedeutung: 
 
       </locale> 
    </locale> 
 
<delete> 
 
<define name="openmodes" type=open_close_tag> 
function openmodes( text ) { 
  print( "<table>" ); 
  print( text ); 
  print( "</table>" ); 
} 
</define> 
 
<define name="openmode" PAR_1="mode" PAR_2="title-de" PAR_3="title-en"> 
function openmode( mode, title_de, title_en ) { 
 
  tspace(); 
  print( "<tr>" ); 
  print( "<td valign=top><code><b>", mode, "</b></code></td>" ); 
  print( "<td>&nbsp;</td>" ); 
 
  var title; 
   
  <locale> 
    <locale language="de"> 
 
  title= title_de; 
 
    </locale> 
    <locale language="en"> 
 
  title = title_en; 
 
    </locale> 
  </locale> 
 
  print( "<td>", title, "</td>" ); 
  print( "</tr>" ); 
   
} 
</define> 
 
</delete> 
 
  <openmodes> 
    <openmode mode=r title-en="Open file for read access."                      title-de="Öffne Datei zum Lesen."> 
    <openmode mode=w title-en="Open file for write access."                      title-de="Öffne Datei zum Schreiben."> 
    <openmode mode=a title-en="Open for writing and append data to the file."                      title-de="Öffne Datei zum Schreiben und hänge Daten an die Datei an."> 
    <openmode mode=t title-en="If file exist erase the data."                      title-de="Wenn Datei existiert, dann lösche den Inhalt."> 
  </openmodes> 
   
  </faq> 
 
 
   
  <faq title="Bool nocreate"> 
 
  <locale> 
    <locale language="en"> 
 
  If the parameter is <code>true</code>, opening a file will fail if the file does not exists. 
  The default value is <code>false</code>. 
 
    </locale> 
    <locale language="de"> 
 
  Wenn der Parameter <code>true</code> ist, dann schlägt das Öffnen einer Datei fehl, wenn die 
  Datei nicht existiert. Der default Wert dieser Option ist <code>false</code>. 
   
    </locale> 
  </locale> 
   
  </faq> 
 
 
   
  <faq title="Bool realfile"> 
 
  <lang en text="If the parameter is <code>true</code> a real file would be used.                 If not, a virtual file will be used."> 
  <lang de text="Ist der Parameter <code>true</code> wird eine reelle Datei verwendet.                 Wenn nicht, dann wird eine virtuelle Datei verwendet."> 
  </faq> 
   
</faq> 
 
<!-- *********************************** --> 
 
<faq title="Bool is_valid()"> 
 
<locale> 
   <locale language="de"> 
 
Wenn die Klasse und die Datei auf die sie zeigt gültig sind, 
dann wird hier <code>true</code> zurückgegeben. 
 
   </locale> 
   <locale language="en"> 
 
If the class and it's file are valid, the function will 
return <code>true</code> 
 
   </locale> 
</locale> 
   
</faq> 
 
<!-- ********************************** --> 
   
<faq title="String get_name()"> 
 
<locale> 
  <locale language="de"> 
 
Die Funktion gibt den Namen der Datei zurück. 
Dies funktioniert sogar dann nachdem die Klasse ungältig geworden ist, 
also <b>is_valid()</b> <code>false</code> zurückliefert. 
 
  </locale> 
  <locale language="en"> 
 
The function returns the name of the file. 
This will even work after the class becomes invalid, after 
<b>is_valid</b> returns <code>false</code>. 
 
  </locale> 
</locale> 
 
<example mode=fixed> 
  <char latin1> 
 
function open_file( name ) { 
 
  var file = new File( name, "r", true, true ); 
 
  if( ! file.is_valid() ) { 
    message( "cannot open file", file.get_name() ); 
    return; 
  } 
 
  // .... 
} 
 
  </char> 
</example> 
   
</faq> 
 
<!-- ******************************** --> 
 
<faq title="Null trunc()"> 
 
<lang en text="Erase the data of the file."> 
<lang de text="Lösche den Inhalt der Datei."> 
 
</faq> 
 
<!-- ***************************** --> 
 
<faq title="Bool eof()"> 
 
<locale> 
  <locale language="en"> 
 
Returns <code>true</code> if the end of the file has been reached. 
It will return <code>true</code> until <b>clear()</b> has benn called. 
 
  </locale> 
  <locale language="de"> 
 
Gibt <code>true</code> zurück wenn das Ende der Datei erreicht wurde. 
Es wird solange <code>true</code> zurückgegeben bis <b>clear()</b> aufgerufen wurde. 
 
  </locale> 
</locale> 
 
</faq> 
 
<!-- ****************************** --> 
 
<faq title="Null flush()"> 
 
<lang en text="Flushes the buffer and writes all data to the file."> 
<lang de text="Erzwingt das schreiben aller gepufferten Daten in die Datei."> 
 
</faq> 
 
<!-- ****************************** --> 
 
<faq title="Integer tellg()"> 
 
<lang en text="Returns the Position of the read pointer of the file."> 
<lang de text="Gibt die Position des Lese-Zeigers der Datei zurück."> 
 
</faq> 
 
 
<!-- ****************************** --> 
 
<faq title="Integer tellp()"> 
 
<lang en text="Returns the Position of the write pointer of the file."> 
<lang de text="Gibt die Position des Schreib-Zeigers der Datei zurück."> 
 
</faq> 
 
 
<!-- ****************************** --> 
 
<faq title="Null seekg( Integer pos )"> 
 
<lang en text="Moves the read pointer to the position in the file."> 
<lang de text="Setzt die Position des Lese-Zeigers der Datei."> 
 
</faq> 
 
 
<!-- ****************************** --> 
 
<faq title="Null seekp( Integer pos )"> 
 
<lang en text="Moves the write pointer to the position in the file."> 
<lang de text="Setzt die Position des Schreib-Zeigers der Datei."> 
 
</faq> 
 
</section> 
 
<!-- **************************** --> 
 
<faq title="Integer get()"> 
 
<lang en text="Returns the next character of the file."> 
<lang de text="Gibt das nächste Zeichen der Datei zurück."> 
 
</faq> 
 
 
<!-- **************************** --> 
 
<faq title="put( Integer c )"> 
 
<lang de text="Schreibt das gegebene Zeichen in die Datei."> 
<lang en text="Writes the character to the file."> 
 
</faq> 
 
<!-- **************************** --> 
 
<faq title="String read( Integer n )"> 
 
<lang en text="Reads n characters from the file."> 
<lang de text="Liest n Zeichen aus der Datei."> 
 
</faq> 
 
<!-- **************************** --> 
 
<faq title="Null write( String s )"> 
 
<lang de text="Schreibt die Zeichenkette s in die Datei."> 
<lang en text="Writes the string s to the file."> 
 
</faq> 
 
 
<!-- **************************** --> 
 
<faq title="Null write( String s, Integer n )"> 
 
<lang de text="Schreibt n Zeichen, der Zeichenkette s in die Datei."> 
<lang en text="Writes n characters of the string s to the file."> 
 
</faq> 
 
<!-- **************************** --> 
 
<faq title="String getline()"> 
 
<lang en text="Reads a line from the file."> 
<lang de text="Liest eine Zeile aus der Datei."> 
 
</faq> 
 
<!-- **************************** --> 
 
<faq title="Null append( File other_file )"> 
 
<lang en text="Appends the given file to the current file."> 
<lang de text="Hängt einen gegebene Datei an die momentane Datei an."> 
 
</faq> 
 
<!-- ***************************** --> 
 
<faq title="Null reference( File other_file )"> 
 
<locale> 
  <locale language="en"> 
 
The function copies the other file pointer data to this class. 
In other words, it copies the other_file to this class. It's the same 
like opening the file of the other class once again. 
 
  </locale> 
  <locale language="de"> 
 
Die Funktion kopiert den Dateizeiger der anderen Klasse auf diese Klasse. 
In anderen Worten die Klassen werden einfach kopiert. Es das selbe, wie wenn 
du die Datei der anderen Klasse normal öffnest. 
 
  </locale> 
</locale> 
 
<example mode=fixed> 
<char latin1> 
 
var file1 = new File( "foo.txt", "rw" ); 
 
 
<lang de text="// erste Methode"> 
<lang en text="// fisrt method"> 
var file2 = new File( "foo.txt", "rw" ); 
 
<lang de text="// zweite Methode"> 
<lang en text="// second method"> 
var file2 = new File(); 
 
file2.reference( file1 ); 
 
</char> 
</example> 
 
<br><br> 
 
<locale> 
  <locale language="de"> 
 
Nocheinmal: Dies hat aber keine Auswirkungen auf die reelle Datei. Es wird nur 
der Zeiger auf die Datei kopiert.<br> 
Nach der benutztung dieser Funktion bitte überprüfe die Gültigkeit der Klasse 
mit der <b>is_valid()</b> Funktion. 
 
 
   </locale> 
   <locale language="en"> 
 
Again: this won't copy the real file, only the pointer on the file.<br> 
After using this function you'll have to check if the file is valid by 
using <b>is_valid()</b>. 
 
  </locale> 
</locale> 
 
</faq> 
 
<p> 
 
<locale> 
  <locale language="de"> 
 
An example for the usage of the <code>Line</code> class you will find there: 
<link path="/lexer/example"> 
 
  </locale> 
  <locale language="en"> 
 
Ein Beispiel für die benutztung der <code>Line</code> Klasse findest du hier: 
<link path="/lexer/example"> 
 
  </locale> 
</locale> 
 
</p> 
 
<!-- ***************************** --> 
 
                  
    



Diese Seite wurde von King Leo kreiert. Seitengenerator Leo<HTML> Version 0.99.0 .