[Oberon] FPGA Oberon - Lost file reclaim storage

thomas.kral at email.cz thomas.kral at email.cz
Fri Mar 24 11:01:17 CET 2017


Hi Joerg,



Thank you. Based on your example, I coded this module, it has this toolbox




Dir.List - enumerate directory with sectors

Dir.Find - find files by secs, and dump their names in dec

Dir.Delete - delete files by secs




It is interesting that file with a strange header, had the byte 255 in the 
place of dot '.'

Dir.Delete seems to have removed it.




----------------------------------------------------------------------------
----------------------





MODULE Dir; (*TK 24.3.2017*)

  IMPORT Texts, FileDir, Oberon;

  VAR W: Texts.Writer; fsec: INTEGER;




  PROCEDURE ListSec(name: FileDir.FileName; sec : INTEGER; VAR cont: 
BOOLEAN);

  BEGIN

     Texts.WriteString(W, name); Texts.WriteString(W, " ");

     Texts.WriteInt(W, sec, 6);

     Texts.WriteLn(W);

     cont := TRUE

  END ListSec;




  PROCEDURE FindSec(name: FileDir.FileName; sec : INTEGER; VAR cont: 
BOOLEAN);

    VAR i: INTEGER; ch: BYTE;

  BEGIN

    IF fsec = sec THEN cont := FALSE; 

      Texts.WriteString(W, name); Texts.WriteString(W, " ");

      i := 0; REPEAT ch := ORD(name[i]); Texts.WriteInt(W, ch, 4);  INC(i); 
UNTIL ch = 0;

      Texts.WriteInt(W, sec, 6);

      Texts.WriteLn(W);

    ELSE cont := TRUE 

    END

  END FindSec;




  PROCEDURE DelSec(name: FileDir.FileName; sec : INTEGER; VAR cont: 
BOOLEAN);

  BEGIN

    IF fsec = sec THEN cont := FALSE; 

      Texts.WriteString(W, name); Texts.WriteInt(W, sec, 6); Texts.
WriteString(W, " deleting");

      FileDir.Delete(name, sec);

      Texts.WriteLn(W);

    ELSE cont := TRUE 

    END

  END DelSec;




  PROCEDURE List*;

  BEGIN 

    FileDir.Enumerate("", ListSec); Texts.Append(Oberon.Log, W.buf)

  END List;




  PROCEDURE Find*;

    VAR S: Texts.Scanner;

  BEGIN

    Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);

    WHILE S.class = Texts.Int DO fsec := S.i; 

      FileDir.Enumerate("", FindSec); Texts.Append(Oberon.Log, W.buf); 
Texts.Scan(S)

    END

  END Find;




  PROCEDURE Delete*;

    VAR S: Texts.Scanner;

  BEGIN

    Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);

    WHILE S.class = Texts.Int DO fsec := S.i; 

      FileDir.Enumerate("", DelSec); Texts.Append(Oberon.Log, W.buf); Texts.
Scan(S)

    END

  END Delete;




BEGIN Texts.OpenWriter(W)

END Dir.













---------- Původní zpráva ----------
Od: Jörg <joerg.straube at iaeth.ch>
Komu: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Datum: 23. 3. 2017 10:16:43
Předmět: Re: [Oberon] FPGA Oberon - Lost file reclaim storage

"

Yes, it's indeed a recursive directory traverse.

If you have found your strange file (by checking "name") a call to FileDir.
Delete(name, sec) should do. After the delete set cont := FALSE and the 
recursion will stop.


Jörg




BTW: my code was already Oberon-7 :-) The first thing I did is I compiled 
the rather portable module Out.Mod as its main task is to simplify writing 
to Oberon.Log...

https://github.com/Spirit-of-Oberon/ETH-Oberon-PlugIn-Win32/blob/master/Src/
Out.Mod.txt
(https://github.com/Spirit-of-Oberon/ETH-Oberon-PlugIn-Win32/blob/master/Src/Out.Mod.txt)




Am 22.03.2017 um 19:14 schrieb <thomas.kral at email.cz
(mailto:thomas.kral at email.cz)> <thomas.kral at email.cz
(mailto:thomas.kral at email.cz)>:


"
Hi Joerg,



Interesting, is this a recursive directory traverse?

It indeed reports one the files in question and its sector(start?) number.




Tomas




---




Recoded for revised FPGA (V7?) Oberon as below, still struggling a bit with 
terminology. 





MODULE MyDir;

  IMPORT Texts, FileDir, Oberon;

  VAR W: Texts.Writer;




  PROCEDURE List(name: FileDir.FileName; sec : INTEGER; VAR cont: BOOLEAN);

  BEGIN

     Texts.WriteString(W, name); Texts.WriteInt(W, sec, 6);

     Texts.WriteLn(W);

     cont := TRUE

  END List;

 

  PROCEDURE Do*;

  BEGIN 

    FileDir.Enumerate("", List); Texts.Append(Oberon.Log, W.buf)

  END Do;




BEGIN Texts.OpenWriter(W);

END MyDir.




---------- Původní zpráva ----------
Od: Jörg <joerg.straube at iaeth.ch(mailto:joerg.straube at iaeth.ch)>
Komu: 'ETH Oberon and related systems' <oberon at lists.inf.ethz.ch
(mailto:oberon at lists.inf.ethz.ch)>
Datum: 22. 3. 2017 18:04:00
Předmět: Re: [Oberon] FPGA Oberon - Lost file reclaim storage

"


Thomas

 

Can you still enumerate the corrupted file?

I mean, will this program find your file?

 

MODULE myDir

 

IMPORT FileDir, Out;

 

PROCEUDRE List(name: FileDir.FileName; sec: INTEGER; VAR cont: BOOLEAN);

            BEGIN

                        Out.String(name); Out.Int(sec, 12); Out.Ln;

                        cont := TRUE

            END List;

 

PROCEDURE Do*;

            BEGIN

                        FileDir.Enumerate(“”, List)

            END Do;

BEGIN

END myDir.Do

 

 


 
 From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch
 (mailto:oberon-bounces at lists.inf.ethz.ch)] On Behalf Of thomas.kral at email.
 cz(mailto:thomas.kral at email.cz)
 Sent: Dienstag, 21. März 2017 09:53
 To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch
 (mailto:oberon at lists.inf.ethz.ch)>
 Subject: [Oberon] FPGA Oberon - Lost file reclaim storage
 


 

Hi,


 



On a very rare occasion, I happened to produce a file that has a corrupt 
header, wherby a dot '.' in its name is replaced by an invisible character.



 



Subsequent writing to the same file name resolved the situation and file was
created normally. 



 



Now I am just thinking how I can reclaim the storage taken up by that lost 
file. Delete on its name fails, as the system does not see it as a regular 
file. 



 



Tomas



-- 
Oberon at lists.inf.ethz.ch(mailto:Oberon at lists.inf.ethz.ch) mailing list for 
ETH Oberon and related systems 
https://lists.inf.ethz.ch/mailman/listinfo/oberon
(https://lists.inf.ethz.ch/mailman/listinfo/oberon) 
"

""
--
Oberon at lists.inf.ethz.ch(mailto:Oberon at lists.inf.ethz.ch) mailing list for 
ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon
(https://lists.inf.ethz.ch/mailman/listinfo/oberon)

"
-- 
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems 
https://lists.inf.ethz.ch/mailman/listinfo/oberon 
"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20170324/eb444aab/attachment.html>


More information about the Oberon mailing list