To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.dev.org.ldrawOpen lugnet.cad.dev.org.ldraw in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Development / Organizations / LDraw / 107
106  |  108
Subject: 
Re: IMPORTANT - [ldraw.org] Official Model Repository
Newsgroups: 
lugnet.cad.dev.org.ldraw, lugnet.cad.dev
Date: 
Sun, 13 Jun 1999 18:32:59 GMT
Viewed: 
934 times
  
In lugnet.cad.dev.org.ldraw, braml@juno.com (Bram Lambrecht) writes:
I wrote:
Unzipping or splitting an MPD should create the directories correctly
if they don't already exist (I hope).  We should check if splitting an
MPD with the current software does that.

I did some testing.  LDLite functions fine with subdirs in MPD filenames
(ex:
0 FILE foo\bar\test.dat
works fine, as long as any references to that file are
1 ... foo\bar\test.dat
LDraw works fine with subdirs, as we already knew.

Awesome.  That's so cool!

One question, though:  Does it require backslashes or does it allow forward
slashes as well?


The problems are with the MPD splitters.  Jacob's MPD splitter works fine
as long as the subdirectory already exists.  However, in most cases, the
subdir will *not* exist before splitting.  Onyx's M-Peedy claims to have
split the MPD correctly, but the files are nowhere to be found.

Onyx and Jacob, is it possible to enhance your programs to correctly
create subdirectories when an MPD has a path instead of just a filename
after the 0 FILE marker?

It looks like I have the same bug in mpdgarp*.  Fortunately, some OS's allow
the -p option on calls to the mkdir program:

   -p  Create intermediate directories as required.  If this option is
       not specified, the full path prefix of each operand must already
       exist.  Intermediate directories are created with permission bits
       of rwxrwxrwx (0777) as modified by the current umask, plus write
       and search permission for the owner.

So that's a Q&D way to fix it, but not a very platform-independent one.
It's easy enough, though, in any language/OS combination, to split a
filename on slash or backslash and call the language's built-in mkdir
function down the tree as needed.  In raw Perl this might go something like:

   :
   # obtain filename (assume relative to current working directory)
   :
   my @dirs = split /[\/\\]/, $filename;
   pop @dirs;  # Remove filename, possibly leaving @dirs empty.
   for (0..$#dirs)
   {
      $dirs[$_] ne ".." or die "$filename contains '..'";
      my $path = join("/", @dirs[0..$_]);
      next if -d $path;
      -f $path and die "Regular file already exists at $path";
      mkdir($path, 0777) or die "Couldn't create $path";
   }
   :
   # write data to filename
   :

--Todd


* http://www.lugnet.com/news/display.cgi?lugnet.cad.dev:212



Message has 1 Reply:
  Re: IMPORTANT - [ldraw.org] Official Model Repository
 
(...) Just tested: LEdit, LDraw, LDLite, and Jacob's MPD-Splitter all work with forward slashes as well! (Again, for Jacob's splitter, the dir must already exist.) --Bram (25 years ago, 13-Jun-99, to lugnet.cad.dev.org.ldraw, lugnet.cad.dev)

Message is in Reply To:
  Re: IMPORTANT - [ldraw.org] Official Model Repository
 
(...) I did some testing. LDLite functions fine with subdirs in MPD filenames (ex: 0 FILE foo\bar\test.dat works fine, as long as any references to that file are 1 ... foo\bar\test.dat LDraw works fine with subdirs, as we already knew. The problems (...) (25 years ago, 13-Jun-99, to lugnet.cad.dev.org.ldraw, lugnet.cad.dev)

94 Messages in This Thread:








































Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR