× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Joel,

IBM provides so freebie IFS add-on commands. One of them is DELTREE. I don't 
have access to any e-mail before today at the moment so I don't know the URL to 
the site. There's also a program in the RedBook "Who Knew You Could Do That In 
RPGIV?" that will list out all of the files starting at a given path (it will 
do subdirectories as well). The program just does a listing but you could 
modify it to call unlink() and rmdir() instead.

Matt

-----Original Message-----
From: Joel Cochran [mailto:jrc@xxxxxxxxxx]
Sent: Thursday, September 04, 2003 10:35 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: QzshSystem API


OK, just in case anyone is still following this thread, here's where I
am now:

I'm using the mkdir() API to create the directory and then issuing a
system command to CPY the directory, like so:

 /free
   qshErrorCode = mkdir( localDir : S_IRWXU + S_IRWXG + S_IRWXO );
   // Just for Debug
   p_errno = getErrNo();
   errorMessage = %str( strerror( errno ) );

   cmdString =
     'CPY OBJ(' + singleQuote + '/datacds/def' + singleQuote + ') ' +
     'TODIR(' + singleQuote + localDir + singleQuote + ') ' +
     'SUBTREE(*ALL)' ;
   systemCall( cmdString );
 /end-free

This works for a new directory, but if the directory already exists I
want to delete it and replace it with my new directory.  The problem is
that the rmdir() API will not delete the directory if it has stuff in
it, and rightfully so because that is the way the Unix rmdir command
works.  (Same with the RMVDIR Command).  Normally to get around this I
would issue the following command:

rm -r myDirectory

But in order to do that I am right back to trying to get QzshSystem to
work again.  Before I go back down that path, is there another way?  I
found the unlink() API in Scott's documentation, but it appears to only
work for a single file.  Since I am trying to remove a directory that
will also have sub-directories and files this could get very hairy.  I
would have to do something like dump the ls contents into a file, find
the sub-directories and dump their contents, and start using unlink()
from the bottom up, then rmdir() the sub-directories, and so on.  Ugh.

I could simply use the rename() API and rename my directory to something
else and manually delete it later, but I'm trying to avoid the manual
thing altogether.

Any suggestions or should I go back to QzshSystem()?

Thanks,

Joel
http://www.rpgnext.com


On Wed, 2003-09-03 at 18:04, Scott Klement wrote:
> On Wed, 3 Sep 2003, Walden H. Leverich III wrote:
> > >
> > > Well, for mkdir you could just use the API... that'd be much easier...
> >
> > If the API worked to issue the mkdir command then this entire thread
> > would never have started.  I began by using QzshSystem() to try and
> > simply create a directory.
> >
> 
> I was referring to the mkdir() API, not the QzshSystem API.   mkdir() is
> a much easier API to use from an RPG program.  More info here:
> 
> http://www.scottklement.com/rpg/ifs_ebook/mkdir.html
> 
> 
> > > In order to make it run without using STRQSH, you'd have to set up the
> > > descriptors 0,1,2 which are expected to always work for a Unix program.
> > > RPG doesn't do that for you by default (though, ILE C or Java probably do)
> >
> > Now I think we're getting somewhere.  I stupidly assumed that the API
> > would handle the necessary grunt work so that I could issue QSH
> > commands.
> 
> It would, if you were running it from Java :)   Note that the QSHELL APIs
> aren't listed under "Programming/APIs" in the information center, but
> rather they're listed under Programming/Java/QSHELL
> 
> >
> > Maybe I'm too basic for this work.  It doesn't matter to me if the
> > commands are Unix or not, in fact I think they should be native OS/400
> > commands.  Copying a directory and it's contents in a supported file
> > system from an application written in a native language should be easy,
> > period.  I'm using the Unix style commands and QSH because I have
> > basically no other option.
> 
> Can't you use the OS/400 CPY command via QCMDEXC?  Something like:
> 
>      CPY OBJ('/datacds') TODIR('/somewhere/else') SUBTREE(*ALL)
> 
> Personally, I think the Unix commands are more intuitive, but then I spend
> a lot of time in FreeBSD, since I use it as an alternative to Windows.
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.