× 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.



Doesn't this example require that the Windows directory be visible through
something like QNTC?

How would this program, which reads an IFS directory, see the Windows
directory?


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of tim
Sent: Wednesday, January 07, 2009 11:13 AM
To: 'Midrange Systems Technical Discussion'
Subject: RE: Can I read a Windows Directory from an RPG program?

D PATHTOLIST C CONST('/TMP/')

D**********************************************************************
D*
D* Directory Entry Structure (dirent)
D*
D* struct dirent {
D* char d_reserved1[16]; /* Reserved
*/
D* unsigned int d_reserved2; /* Reserved
*/
D* ino_t d_fileno; /* The file number of the file
*/
D* unsigned int d_reclen; /* Length of this directory entry
D* * in bytes
*/
D* int d_reserved3; /* Reserved
*/
D* char d_reserved4[8]; /* Reserved
*/
D* qlg_nls_t d_nlsinfo; /* National Language Information
D* * about d_name
*/
D* unsigned int d_namelen; /* Length of the name, in bytes
D* * excluding NULL terminator
*/
D* char d_name[_QP0L_DIR_NAME]; /* Name...null terminated
*/
D*
D* };
D*
D p_dirent s *
D dirent ds based(p_dirent)
D d_reserv1 16A
D d_reserv2 10U 0
D d_fileno 10U 0
D d_reclen 10U 0
D d_reserv3 10I 0
D d_reserv4 8A
D d_nlsinfo 12A
D nls_ccsid 10I 0 OVERLAY(d_nlsinfo:1)
D nls_cntry 2A OVERLAY(d_nlsinfo:5)
D nls_lang 3A OVERLAY(d_nlsinfo:7)
D nls_reserv 3A OVERLAY(d_nlsinfo:10)
D d_namelen 10U 0
D d_name 640A

D*--------------------------------------------------------------------
D* Open a Directory
D*
D* DIR *opendir(const char *dirname)
D*
D* NOTE: We are at V3R2, so we can't use OPTIONS(*STRING) yet :(
D*--------------------------------------------------------------------
D opendir PR * EXTPROC('opendir')
D dirname * VALUE

D*--------------------------------------------------------------------
D* Read Directory Entry
D*
D* struct dirent *readdir(DIR *dirp)
D*
D* NOTE: We are at V3R2, so we can't use OPTIONS(*STRING) yet :(
D*--------------------------------------------------------------------
D readdir PR * EXTPROC('readdir')
D dirp * VALUE


D* a few local variables...
D dh S *
D PathName S 256A
D Name S 256A


C* Step1: Open up the directory.
c eval PathName= PATHTOLIST + x'00'
C eval dh = opendir(%addr(PathName))
C if dh = *NULL
c eval Msg = 'Cant open directory'
c dsply Msg 50
c eval *INLR = *ON
c Return
c endif

C* Step2: Read each entry from the directory (in a loop)
c eval p_dirent = readdir(dh)
c dow p_dirent <> *NULL

C* FIXME: This code can only handle file/dir names under 256 bytes long
C* because thats the size of "Name"
c if d_namelen < 256
c eval Name = %subst(d_name:1:d_namelen)
c movel Name dsply_me 52
c dsply_me dsply
c endif

c eval p_dirent = readdir(dh)
c enddo

C* Step3: End Program
c dsply Pause 1
c eval *inlr = *On

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of DebbieKelemen
Sent: Wednesday, January 07, 2009 12:00 PM
To: 'Midrange Systems Technical Discussion'
Subject: Can I read a Windows Directory from an RPG program?

I have built a series of programs. One of them does a list of the names
from a Windows Directory to a file on the iSeries. This file contains jpg
images that we load to our website. I need to verify that the image exists
before I include it in our emails that we send to customers.



My Department Manager says this is "kluge" or just error prone. He wants me
to directly read the Windows Directory from the RPG program.



Can someone point me in the right direction, please?



Debbie Kelemen

Sr. Programmer / Analyst

CHEFS

719-272-2617

dkelemen@xxxxxxxxxxxxxxxx

www.chefscatalog.com










As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.