Page 1 of 1

StdCoder Separator

PostPosted: Fri Dec 21, 2018 7:59 am
by luowy
I don't know if this error has been fixed in the center copy. In my copy it has been fixed:
StdCoder
Code: Select all
   ....
      Separator = "/";
      Separator2="\";(*add*)


StdCoder.GetFile
Code: Select all
   PROCEDURE GetFile(VAR path: ARRAY OF CHAR; VAR loc: Files.Locator; VAR name: Files.Name);
      VAR i, j: INTEGER; ch: CHAR;
   BEGIN
      i := 0; ch := path[0]; loc := Files.dir.This(""); name := "";
      WHILE (ch # 0X) & (loc.res = 0) DO
         j := 0;
         WHILE (ch # 0X) & (ch # Separator)&(ch # Separator2) DO name[j] := ch; INC(j); INC(i); ch := path[i] END;
         name[j] := 0X;
         IF (ch = Separator) OR (ch = Separator2) THEN loc := loc.This(name); INC(i); ch := path[i] END;
      END;
      IF loc.res # 0 THEN loc := NIL END;
      path[i] := 0X
   END GetFile;

the test file is here https://blackbox.obertone.ru/download/Flash.txt

luowy

Re: StdCoder Separator

PostPosted: Wed Dec 26, 2018 8:35 pm
by Josef Templ
As far as I know this has not been reported and it certainly has not been fixed.

- Josef

Re: StdCoder Separator

PostPosted: Fri Dec 28, 2018 9:22 am
by Josef Templ
The docu of StdCoder.EncodeFileList says that "/" should be used as separator.
It does not mention "\". Using "\" as separator makes implicit use of
the fact that under Windows (HostFiles) "\" can be used as a file separator.

Supporting "\" in StdCoder.EncodeFileList is tempting but has the disadvantage of
making StdCoder dependent on a particular HostFiles implementation without
showing this dependency in the import list.

- Josef

Re: StdCoder Separator

PostPosted: Fri Dec 28, 2018 11:58 am
by luowy
that means it's not a bug...
But how was the example file created? Under which release?
Can our center distribution create such a file?
Maybe Ivan can get the answer form its author.

Re: StdCoder Separator

PostPosted: Sat Dec 29, 2018 10:55 am
by Josef Templ
The center version can create such a file and the center version can even decode such a file
but only if all directories already exist. It fails when creation of a directory is required because
it skips the separator that marks the directory name needed for creating a new directory.
Creating a file and creating a directory are separated under Windows and are also separated
in the BlackBox Files module.

- Josef

Re: StdCoder Separator

PostPosted: Mon Dec 31, 2018 2:12 pm
by Zinn
Josef Templ wrote:The center version can create such a file and the center version can even decode such a file
but only if all directories already exist.

But with Luowy's patches the directory is created during decode automatically.
- Helmut

Re: StdCoder Separator

PostPosted: Mon Dec 31, 2018 2:54 pm
by Josef Templ
Well, there are other modules as well that use "\" as alternative separator, for example StdApi.
It seems that this violation of abstraction is unavoidable unless there is some
additional (Files) function that checks for valid file names.

Given that observation I tend to agree with luowy's proposal.

- Josef