[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: help - IFS
Thanks for the help
-----Original Message-----
From: [1]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ronnie
Sent: 16 August 2012 02:33 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: help - IFS
Hi Giel.
You can use this.
D/copy dcpyb/qs36src,IFSIO_H
d dir s *
D Msg S 256A
D wDirPath s 256
D wfpath s 256
D wfullpath s 256
/free
wfpath = '/tmp/ronnie/';
//must add hex 00 to the end
wfullpath = %trim(wfpath) + x'00';
dir = opendir(%addr(wfullpath));
if dir <> *NULL;
p_dirent = readdir(dir);
dow p_dirent <> *NULL;
Msg = %subst(d_name:1:d_namelen);
if msg <> '.'
and msg <> '..'
and msg <> *blanks;
wdirpath = %trim(wfpath)
+ %trim(msg) + x'00';
//this is now your full path plus the file name//
//do whatever you want to do with the file read it etc.//
endif;
p_dirent = readdir(dir);
enddo;
callp closedir(dir);
endif;
Alternatively you can use this proc which you can call for one
directory and it will call itself recursively for subdirs.
D do_dir PR 10I 0
D peDir 640A const
D errno PR 10I 0
D is_dir PR 1A
D peDir 640A const
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// This procedure calls itself recursively for each subdirectory
// in a directory.
//
// For each non-subdir in the directory, it handles the file
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P do_dir B
D do_dir PI 10I 0
D peDir 640A const
D dh S *
D wwDirname S 640A
D wwFile S 640A
D wwLen S 10I 0
D FtpDir S 640A
D LocalDirp S 640A
D LocalFile S 640A
D wdPos S 10I 0
D mystat s like(statds64)
// Strip off trailing '/'
/FREE
wwLen = %len(%trimr(peDir));
if wwLen>1 and %subst(peDir:wwLen:1) = '/';
wwDirname = %subst(peDir:1:wwLen-1);
else;
wwDirname = peDir;
endif;
LocalDirp = peDir;
// Open local directory
dh = opendir(%trimr(LocalDirp));
if dh = *NULL;
diagmsg('opendir(): ' +
%str(strerror(errno)));
return -1;
endif;
dow 1 = 1;
// Read next directory entry
p_dirent = readdir(dh);
if p_dirent = *NULL;
leave;
endif;
// Skip special files "." and ".."
wwFile = %subst(d_name: 1: d_namelen);
if wwFile = '.' or wwFile = '..';
iter;
endif;
// Get stat structure for local file
if %subst(LocalDirp:%len(%trim(LocalDirp)):1) = '/';
LocalFile = %trim(LocalDirp) + wwFile;
else;
LocalFile = %trim(LocalDirp) + '/' + wwFile;
endif;
if stat(%trimr(LocalFile): %addr(mystat))<0;
diagmsg('stat(): ' + %trim(wwFile) +
': ' + %str(strerror(errno)));
endif;
// If local file is a directory, call this procedure again,
// with the new directory name.
p_statds64 = %addr(mystat);
if S_ISDIR(st_mode);
//if you want to something because it is a directory put it here
if %subst(LocalDirp:%len(%trim(LocalDirp)):1) = '/';
if do_dir(%trimr(LocalDirp) +
wwFile:*blanks) < 0;
return -1;
endif;
else;
if do_dir(%trimr(LocalDirp) + '/' +
wwFile:*blanks) < 0;
return -1;
endif;
endif;
else;
// Otherwise, assume it's a file, and do something with it. //do file
processing here
//I usually have a separate proc or program to deal the file.
//So I always call some program here passing the full file name
//I have though about making it a parm to the proc which will
//make it more reusable but not there yet.
ENDIF;
enddo;
closedir(dh);
return 0;
/END-FREE
P E
You are going to need this as well (cant recall where I got this but I
think it was from one of Scott's sites).
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* This tests a file mode to see if a file is a directory.
*
* Here is the C code we're trying to duplicate:
* #define _S_IFDIR 0040000 */
* #define S_ISDIR(mode) (((mode) & 0370000) == _S_IFDIR)
*
* 1) ((mode) & 0370000) takes the file's mode and performs a
* bitwise AND with the octal constant 0370000. In binary,
* that constant looks like: 00000000000000011111000000000000
* The effect of this code is to turn off all bits in the
* mode, except those marked with a '1' in the binary bitmask.
*
* 2) ((result of #1) == _S_IFDIR) What this does is compare
* the result of step 1, above with the _S_IFDIR, which
* is defined to be the octal constant 0040000. In decimal,
* that octal constant is 16384.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P S_ISDIR B
D S_ISDIR PI 1N
D mode 10U 0 value
D DS
D dirmode 1 4U 0
D byte1 1 1A
D byte2 2 2A
D byte3 3 3A
D byte4 4 4A
* Turn off bits in the mode, as in step (1) above.
c eval dirmode = mode
c bitoff x'FF' byte1
c bitoff x'FE' byte2
c bitoff x'0F' byte3
c bitoff x'FF' byte4
* Compare the result to 0040000, and return true or false.
B01 c if dirmode = 16384
c return *On
X01 c else
c return *Off
E01 c endif
P E
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get the UNIX/C error number
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P errno B
D errno PI 10I 0
D p_errno S *
D wwreturn S 10I 0 based(p_errno)
/FREE
p_errno = c__errno;
return wwreturn;
/END-FREE
P E
Ronnie Visser
+27 11 012 8700.
082 322 7920
-----Original Message-----
From: [2]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Giel van
der Merwe
Sent: Thursday, August 16, 2012 1:56 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: help - IFS
This looks like a good way to go I tried adding it to a rpg program
c eval p_dirent = readdir(d)
c dow p_dirent <> *NULL
C* ...do whatever we like with the contents
C* of the dirent structure, here...
c eval p_dirent = readdir(d)
c enddo
but I am not sure how to define "D", would you know, I tried replacing
it with '/QDLS/GIEL'
-----Original Message-----
From: [3]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Craig
Jacobsen
Sent: 16 August 2012 12:47 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: help - IFS
Giel,
I would just use readdir using Scott's IFS stuff.
Here is a reference:
[4]http://www.scottklement.com/rpg/ifs_ebook/readdir.html
Craig
-----Original Message-----
From: [5]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Giel van
der Merwe
Sent: Wednesday, August 15, 2012 3:58 PM
To: [6]ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: help - IFS
I get sent a XML file that is placed on the IFS in a dedicated library,
but the file name changes, what would you recommend I do to get the
file name, so that I could process in my RPGLE program, any ideas?
Giel van der Merwe
#######################################################################
##############
The provisions of Sections 11,12, and 13 of the Electronic
Communications and Transactions Act, 25 of 2002, in so far as
e-contracting is concerned is expressly excluded and contracted out by
Barloworld South Africa (Pty) Ltd ("Barloworld") and no data message or
electronic communication will be recognised as having legal contractual
status as per the aforementioned provisions under any circumstances.
All contracts concluded by Barloworld, its Business Units, Divisions
and Subsidiaries will only be legally binding and recognised once
reduced to physical writing and physically signed by a duly authorised
representative of Barloworld.
All other provisions of the Electronic Communications and Transactions
Act, 25 of 2002 are accepted.
#######################################################################
##############
Note:
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and
all copies of it from your system, destroy any hard copies of it and
notify the sender. You must not, directly or indirectly, use, disclose,
distribute, print, or copy any part of this message if you are not the
intended recipient. Avis and any of its subsidiaries each reserve the
right to monitor all e-mail communications through its networks.
Any views expressed in this message are those of the individual sender,
except where the message states otherwise and the sender is authorized
to state them to be the views of any such entity.
Thank You.
#######################################################################
##############
Confidentiality Notice: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply e-mail and destroy all
copies of the original message. Unless expressly stated in this e-mail,
nothing in this message or any attachment should be construed as a
digital or electronic signature.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
[7]http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
#######################################################################
##############
The provisions of Sections 11,12, and 13 of the Electronic
Communications and Transactions Act, 25 of 2002, in so far as
e-contracting is concerned is expressly excluded and contracted out by
Barloworld South Africa (Pty) Ltd ("Barloworld") and no data message or
electronic communication will be recognised as having legal contractual
status as per the aforementioned provisions under any circumstances.
All contracts concluded by Barloworld, its Business Units, Divisions
and Subsidiaries will only be legally binding and recognised once
reduced to physical writing and physically signed by a duly authorised
representative of Barloworld.
All other provisions of the Electronic Communications and Transactions
Act, 25 of 2002 are accepted.
#######################################################################
##############
Note:
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and
all copies of it from your system, destroy any hard copies of it and
notify the sender. You must not, directly or indirectly, use, disclose,
distribute, print, or copy any part of this message if you are not the
intended recipient. Avis and any of its subsidiaries each reserve the
right to monitor all e-mail communications through its networks.
Any views expressed in this message are those of the individual sender,
except where the message states otherwise and the sender is authorized
to state them to be the views of any such entity.
Thank You.
#######################################################################
##############
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
[8]http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
[9][cid:112081707101901202@mail40.mimecast.co.za]
_______________________________________________________________________
The provisions of Sections 11,12, and 13 of the Electronic
Communications and Transactions Act, 25 of 2002, in so far as
e-contracting is concerned is expressly excluded and contracted out by
Barloworld South Africa (Pty) Ltd ("Barloworld") and no data message or
electronic communication will be recognised as having legal contractual
status as per the aforementioned provisions under any circumstances.
All contracts concluded by Barloworld, its Business Units, Divisions
and Subsidiaries will only be legally binding and recognised once
reduced to physical writing and physically signed by a duly authorised
representative of Barloworld.
All other provisions of the Electronic Communications and Transactions
Act, 25 of 2002 are accepted.
_______________________________________________________________________
Note:This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and
all copies of it from your system, destroy any hard copies of it and
notify the sender. You must not, directly or indirectly, use,
disclose, distribute, print, or copy any part of this message if you
are not the intended recipient. Avis and any of its subsidiaries each
reserve the right to monitor all e-mail communications through its
networks.Any views expressed in this message are those of the
individual sender, except where the message states otherwise and the
sender is authorized to state them to be the views of any such entity.
Thank You.
_______________________________________________________________________
References
1. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
2. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
3. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
4. http://www.scottklement.com/rpg/ifs_ebook/readdir.html
5. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
6. mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx
7. http://www.scottklement.com/mailman/listinfo/ftpapi
8. http://www.scottklement.com/mailman/listinfo/ftpapi
9. https://mail40.mimecast.co.za/mimecast/click?account=CSA20A3&code=efa1a1b84fe604c8b62ea87c1c6d69ca
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------