#2649 Representing a Directory from a Uri

JohnNuccio Wed 4 Oct

Is it possible to represent a directory from a Uri like you would represent a single file?

Str filePathWorks := "/rsc/chrome-win/chrome.exe";//This does work
Str filePathDoeNot := "/rsc/chrome-win/";//This does not work

private File loadLocalFile(Str filePath)
{
 //Source any file from the local path in the pod
 pod := typeof.pod;
 f := pod.file(Uri.fromStr(filePath))
 return f;
}

SlimerDude Thu 5 Oct

Is it possible to represent a directory from a Uri like you would represent a single file?

In general, yes, but if you're talking about pod files (as per your example) then, no.

typeof.pod.file(`/fan/`)  // --> sys::UnresolvedErr: fan://acme/fan/

As far as I'm aware, .zip files (and hence .pod files) don't have any notion of directories or directory structure - just individual files with an associated path.

If I may ask, what do you want it for?

If it's just a reference for obtaining other files, then you can use the URI:

** Source a file from the pod
File loadPodFile(Str filePath) {
    typeof.pod.file(`/rsc/chrome-win/` + filePath.toUri)
}

brian Thu 5 Oct

In general directories inside a zip file are typically not first class objects like in a traditional file system. I've seen them both ways (some zip tools support them as first class and some don't). We don't attempt to write directories out into the pod zip file in our compiler.

Login or Signup to reply.