path conversion troubles


    May 02 2006 | 3:58 pm
    I need to convert back and forth between max style pathnames and real Unix paths. This has always been an incredible pain in the behind.
    I searched the archives but the MXJ solution I found is a bit above my head/immediately froze Max.
    Is there an easier way to convert between the 2 styles without resorting to MXJ?
    UNIX (the shell object) doesn't like the G5: (diskname) part nor spaces in pathnames. Escaping with doesn't seem to work.
    All in all, another afternoon lost.
    Yes, I tried absolutepath/relativepath etc.
    It would be great if there was no difference for the user between UNIX and Max paths
    Also, relative and absolute paths in Max are rather messy.

    • May 02 2006 | 8:12 pm
      maybe not what you are looking for, cause it's java, but the class below always worked well for me. if you want, give it a try, send a message [maxToUnix myMaxPath] resp. [unixToMax myUnixPath] hth. volker.
      // name it "vConformPath"
      import com.cycling74.max.*;
      public class vConformPath extends MaxObject { String ppath;
      vConformPath () { declareInlets(new int[] { DataTypes.ALL }); declareOutlets(new int[] { DataTypes.ALL }); }
      // convert max-style path to unix-style public void maxToUnix(String p) { ppath = MaxSystem.maxPathToNativePath(p); //pretty straight forward outlet(0, ppath); System.out.println(ppath); }
      // convert unix-style to max-style path (not so easy, if path is on a partition) public void unixToMax(String p) { ppath = testForPartition(p); outlet(0, ppath); System.out.println(ppath); }
      public String testForPartition(String p) { String partition = null; String path = null; int idx = p.indexOf("/Volumes"); if(idx == -1) //not an external partition path return MaxSystem.nameConform(p, MaxSystem.PATH_STYLE_MAX, MaxSystem.PATH_TYPE_ABSOLUTE); idx = p.indexOf("/", 9); //9 is the first char after "/Volumes/"; partition = p.substring(9,idx); path = p.substring(9 + partition.length()); return new String(partition+":"+path);
      } }
    • May 03 2006 | 5:46 am
      Look into conformpath, part of the standard distri...
      Stefan
      --
      [][] [][][] [][] [][][] [][][][][][][][][][][][][][][]
      Stefan Tiedje Klanggestalter Electronic Composition & Improvisation
      /~~~~~ \ /|() ()| ))))) )| | |( \ /// _/)/ ))))) ___/ ///
      -------------------------x---- --_____-----------|----------- --(_|_ ----|-----|-----()---- -- _|_)----|-----()----------- ----------()------------x-----
      14, Av. Pr. Franklin Roosevelt, 94320 Thiais, France Phone at CCMIX +33-1-57 42 91 09
    • May 03 2006 | 6:43 am
      On 03 May 2006, at 07:46, Stefan Tiedje wrote:
      > Zip Boterbloem wrote: >> Is there an easier way to convert between the 2 styles without >> resorting to MXJ? > > Look into conformpath, part of the standard distri...
      the request was about max/unix-style conversion. conformpath can't handle that. v
    • May 03 2006 | 8:47 am
      vb wrote: >> Look into conformpath, part of the standard distri... > > > the request was about max/unix-style conversion. conformpath can't > handle that.
      what is missing with output type "boot" and style "slash"? I am not the expert for Unix styl paths, but looking at the help file for shell, conform path seems at least be able to get most of the work done...
      Stefan
      --
      [][] [][][] [][] [][][] [][][][][][][][][][][][][][][]
      Stefan Tiedje Klanggestalter Electronic Composition & Improvisation
      /~~~~~ \ /|() ()| ))))) )| | |( \ /// _/)/ ))))) ___/ ///
      -------------------------x---- --_____-----------|----------- --(_|_ ----|-----|-----()---- -- _|_)----|-----()----------- ----------()------------x-----
      14, Av. Pr. Franklin Roosevelt, 94320 Thiais, France Phone at CCMIX +33-1-57 42 91 09
    • May 03 2006 | 10:03 am
      Hi Stefan,
      I tried conformpath, but it doesn't resolve disknames(volumes, in Unix). It just replaces the pathseparators.
      Best,
      Zip Boterbloem Media Mechanics Zwaluwstraat 54 2025 VR Haarlem The Netherlands +31627014758 zip@knoware.nl
    • May 03 2006 | 10:03 am
      Right.
      Zip Boterbloem Media Mechanics Zwaluwstraat 54 2025 VR Haarlem The Netherlands +31627014758 zip@knoware.nl
    • May 03 2006 | 10:05 am
      Hm. Outputstyle boot seems to do the trick.. Nice. I'll do some more tests.
      Best,
      Zip Boterbloem Media Mechanics Zwaluwstraat 54 2025 VR Haarlem The Netherlands +31627014758 zip@knoware.nl
    • May 03 2006 | 10:10 am
      Thanks, vb. I did some reading up on MXJ last night & your example came in really handy. Thanks!
    • May 03 2006 | 3:52 pm
      On 03 May 2006, at 10:47, Stefan Tiedje wrote:
      > vb wrote: >>> Look into conformpath, part of the standard distri... >> the request was about max/unix-style conversion. conformpath >> can't handle that. > > what is missing with output type "boot" and style "slash"?
      as zip pointed out, this works correctly only for files and folders on the boot volume. with other discs or partitions you get the dreaded :/ again.
    • May 03 2006 | 4:10 pm
      On May 3, 2006, at 5:52 PM, vb wrote:
      > as zip pointed out, this works correctly only for files and folders > on the boot volume. > with other discs or partitions you get the dreaded :/ again.
      Can be handled with a regular expression, mapping "name:/" to "/ Volumes/name/" from the output o the boot mode. In future versions we may support an OS X native file string (note that /Volumes/ is not unix standard, but OS X specific).
      -Joshua
    • May 03 2006 | 4:31 pm
      On 03 May 2006, at 18:10, Joshua Kit Clayton wrote:
      > > On May 3, 2006, at 5:52 PM, vb wrote: > >> as zip pointed out, this works correctly only for files and >> folders on the boot volume. >> with other discs or partitions you get the dreaded :/ again. > > Can be handled with a regular expression, mapping "name:/" to "/ > Volumes/name/" from the output o the boot mode. yes, that's exactly what the java snippet i posted earlier is doing (actually based on an example by topher).
    • May 04 2006 | 5:55 am
      vb wrote: > as zip pointed out, this works correctly only for files and folders on > the boot volume. > with other discs or partitions you get the dreaded :/ again.
      yes, but for solving problems we use Max... A solution called "JavaAvoidingConformUnixPath"
      Give it a test, I have no second partition on my Powerbook....
      --
      [][] [][][] [][] [][][] [][][][][][][][][][][][][][][]
      Stefan Tiedje Klanggestalter Electronic Composition & Improvisation
      /~~~~~ \ /|() ()| ))))) )| | |( \ /// _/)/ ))))) ___/ ///
      -------------------------x---- --_____-----------|----------- --(_|_ ----|-----|-----()---- -- _|_)----|-----()----------- ----------()------------x-----
      14, Av. Pr. Franklin Roosevelt, 94320 Thiais, France Phone at CCMIX +33-1-57 42 91 09
    • May 04 2006 | 9:59 am
      On 4 mai 06, at 07:55, Stefan Tiedje wrote:
      > vb wrote: >> as zip pointed out, this works correctly only for files and >> folders on the boot volume. >> with other discs or partitions you get the dreaded :/ again. > > yes, but for solving problems we use Max... > A solution called "JavaAvoidingConformUnixPath"
      Hi Stefan,
      You may have problems with spaces. I know it's just you made you never put spaces in your filenames :-) You can fix that easly while adding the symout argument to the sprintf obect (this is quite recent, an documented).
      The version bellow uses quite human readable regular expression.
      Best, ej
    • May 05 2006 | 6:39 pm
      Joshua Kit Clayton wrote: > Can be handled with a regular expression, mapping "name:/" to > "/Volumes/name/" from the output o the boot mode. In future versions we > may support an OS X native file string (note that /Volumes/ is not unix > standard, but OS X specific).
      To be fair, "volume:/path" is much further from a Unix standard. The unix standard is that volumes are mounted in some subdirectory of the root filesystem. On OS X this happens to default to /Volumes, but regardless of where a file system is mounted, its unix path should look like "/path/to/somevolume".
      The thing that bothers me the most is that many objects (such as jit.qt.movie) don't even understand the /Volumes path. The files are there on the filesystem under /Volumes... Why can't I send jit.qt.movie "read /Volumes/myvolume/file" instead of "read myvolume:/file"?
      At any rate, the feature will be greatly appreciated if/when it is added.
      -charlie
    • May 05 2006 | 9:41 pm
      On 5 May 2006, at 19:39, Charlie wrote:
      > Why can't I send jit.qt.movie > "read /Volumes/myvolume/file" instead of "read myvolume:/file"?
      For all I know, the former might well work (even on Windows if you've only got one device), but the idea behind the whole conformpath thing (volume:path) is portability: a common designation and syntax for (multiple) volumes and files which makes sense both for Mac and Windows.
      There's a pile of conversion machinery in MXJ, and of course [conformpath] in the Max world; it's irritating to have to deal with the stuff, but difficult to avoid if you want portable code.
      -- N.
      nick rothwell -- composition, systems, performance -- http:// www.cassiel.com