RE: [EXTERNAL] How to check if exist in IFS (QTNC) a file

Greg Wilburn <gwilburn-kuYYJ3CQfvZxq3Q2jbZZw/[email protected]>
Newsgroups gmane.comp.hardware.ibm.midrange
Message-ID <PH0PR17MB4863D7414180AAE863D130E3DA382@PH0PR17MB4863.namprd17.prod.outlook.com>
Vern,

I must have missed that.  However, I'm using this inside a "do loop" that's reading directory contents.

Using the prototypes from Scott's IFSIO_H.
FN=Filename (without the path)

       dcl-pi  Ifs_ClrDir         int(10);
         inDir                    varchar(1024) const;
         inMask                   varchar(20) const options(*nopass);
       end-pi;

       dcl-s  rc             int(10);
       dcl-ds entry          based(p_entry) likeds(dirent);
       dcl-s  dh             pointer;
       dcl-s  fn             char(128);
       dcl-s  Stmf           varchar(512);
       dcl-s  fldr           varchar(1024);
       dcl-ds mystat         likeds(statds);
       dcl-s  fileMask       ind inz(*off);

         fldr = %trim(inDir);
         dh = opendir(fldr);                                        // Open a directory
         if dh = *null;
           return -1;
         endif;

         dou p_entry = *null;
           p_entry = readdir(dh);                                   // Read a directory entry

           if (p_entry = *null);                                    // if not end of entries...
             iter;
           endif;

           fn = %subst(entry.d_name:1:entry.d_namelen);             // Filename

           if fn = '.' or                                           // skip . and ..
              fn = '..';
             iter;
           endif;

           Stmf = %trim(fldr) + '/' + %trim(fn);

           rc = stat(%trim(Stmf): mystat);
           if rc < 0;                                               // Move on to next file
             iter;
           endif;

           if %subst(mystat.st_objtype:1:4) = '*DIR';               // Skip folders
             iter;
           endif;

           if fileMask;
             if %scan(inMask:fn) = 0;
               iter;
             endif;
           endif;

           rc = unlink(%trim(Stmf));

         enddo;

         closedir(dh);                                              // Close Directory



From: MIDRANGE-L <midrange-l-bounces-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org> On Behalf Of Vern Hamberg via MIDRANGE-L
Sent: Friday, May 8, 2026 2:28 PM
To: [email protected]
Cc: Vern Hamberg <[email protected]>
Subject: Re: [EXTERNAL] How to check if exist in IFS (QTNC) a file

EXTERNAL EMAIL - This email was sent by a person from outside your organization. Exercise caution when clicking links, opening attachments or taking further action, before validating its authenticity.
Secured by Check Point

Hi Greg

It's been awhile - does stat allow wildcards in the name? The OP asked
about using a partial name. Maybe it'd require something to get a list
with the partial name, then use stat or access on each.

*Regards*

*Vern Hamberg*

IBM Champion 2025 <cid:[email protected]> CAAC
(COMMON Americas Advisory Council) IBM Influencer 2023


On 5/8/2026 8:52 AM, Greg Wilburn wrote:
> I use stat() to check for file size.
>
> rc = stat(%trim(inStmf):mystat);
> if rc < 0;
> return rc;
> endif;
>
> Less than 0 is not found.
>
> From: MIDRANGE-L<midrange-l-bounces-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org<mailto:midrange-l-bounces-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org>> On Behalf Of gio.cot via MIDRANGE-L
> Sent: Friday, May 8, 2026 6:31 AM
> To: 'Midrange Systems Technical Discussion'<[email protected]<mailto:[email protected]>>
> Cc: gio.cot<[email protected]<mailto:[email protected]>>
> Subject: [EXTERNAL] How to check if exist in IFS (QTNC) a file
>
> EXTERNAL EMAIL - This email was sent by a person from outside your organization. Exercise caution when clicking links, opening attachments or taking further action, before validating its authenticity.
> Secured by Check Point
>
> Hi all
>
>
>
> I would need to check in a windows server (mapped via QTNC), if exist a file
> with partial name;
>
> example: if i run "DSPLNK
> OBJ('/qntc/zz-yy-appxx/XT/DOCS/TX/ORDERS/HIST/myfile_26_90501*') , i can
> see that in the folder exist a file named "myfile_26_90501_11052026.txt"
>
> can i do with clp or rpg run a command to check existance passing the file
> partial name ?
>
> usually i use extproc('access') File_Exists = access(pathptr:F_OK)
>
> Thanks in advance
>
> Gio
>
> --
> This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
> To post a message email:[email protected]<mailto:[email protected]>
> To subscribe, unsubscribe, or change list options,
> visit:https://protect.checkpoint.com/v2/r01/___https://lists.midrange.com/mailman/listinfo/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzplNTAzOTY2ODA3ZmIxZDM4MjM3MjNlMWMzMWExNDczMTo3OjQzNDg6MDBlOGNiMGI4MzFlNWFmNGIzMjA4YTI5YTA2MTczYmFlODVlOGU2MDVkY2JmNTk4ZmUzOTk3MDQzY2MxZWUxYzpwOlQ6Rg<https://protect.checkpoint.com/v2/r01/___https:/lists.midrange.com/mailman/listinfo/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzplNTAzOTY2ODA3ZmIxZDM4MjM3MjNlMWMzMWExNDczMTo3OjQzNDg6MDBlOGNiMGI4MzFlNWFmNGIzMjA4YTI5YTA2MTczYmFlODVlOGU2MDVkY2JmNTk4ZmUzOTk3MDQzY2MxZWUxYzpwOlQ6Rg>
> or email:MIDRANGE-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org<mailto:MIDRANGE-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org>
> Before posting, please take a moment to review the archives
> athttps://protect.checkpoint.com/v2/r01/___https://archive.midrange.com/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzplNTAzOTY2ODA3ZmIxZDM4MjM3MjNlMWMzMWExNDczMTo3OjY1Y2Y6OTU0MjE5ZTI3MjIwNDU2OWQwNzc3YWRjZDU5M2M3NTNjYTk3MGE3ZTc3ZDcxZDZlYTdlMWI4ZjYyNTczZGY3YzpwOlQ6Rg<https://protect.checkpoint.com/v2/r01/___https:/archive.midrange.com/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzplNTAzOTY2ODA3ZmIxZDM4MjM3MjNlMWMzMWExNDczMTo3OjY1Y2Y6OTU0MjE5ZTI3MjIwNDU2OWQwNzc3YWRjZDU5M2M3NTNjYTk3MGE3ZTc3ZDcxZDZlYTdlMWI4ZjYyNTczZGY3YzpwOlQ6Rg>.
>
> Please contactsupport-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org<mailto:support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org<mailto:contactsupport-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org%3cmailto:support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org>> for any subscription related questions.
>
> [CAUTION! This email originated outside of the organization. Please do not open attachments or click links from an unknown or suspicious origin.]
>
>
> Greg Wilburn
> Director of IT
> 301.895.3792 ext. 1231
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: [email protected]<mailto:[email protected]>
To subscribe, unsubscribe, or change list options,
visit: https://protect.checkpoint.com/v2/r01/___https://lists.midrange.com/mailman/listinfo/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzo1NzYzNTYyYWIyMmUyOTViMDkxNTdiYjc0YTlhYTg4ODo3OmY1MTU6YzAxYmExZDM2MmI3Zjc2YTU5Yjg5NTM3OWFhOGE1ODE5MjAzNzhiYWNlNzA4NjVkN2Y0YTk5ZTU3NDhlNzdlNDpwOlQ6Rg<https://protect.checkpoint.com/v2/r01/___https:/lists.midrange.com/mailman/listinfo/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzo1NzYzNTYyYWIyMmUyOTViMDkxNTdiYjc0YTlhYTg4ODo3OmY1MTU6YzAxYmExZDM2MmI3Zjc2YTU5Yjg5NTM3OWFhOGE1ODE5MjAzNzhiYWNlNzA4NjVkN2Y0YTk5ZTU3NDhlNzdlNDpwOlQ6Rg>
or email: MIDRANGE-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org<mailto:MIDRANGE-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org>
Before posting, please take a moment to review the archives
at https://protect.checkpoint.com/v2/r01/___https://archive.midrange.com/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzo1NzYzNTYyYWIyMmUyOTViMDkxNTdiYjc0YTlhYTg4ODo3OmE1ZTY6YmEwMThiY2VlZjQzZThmMjcyNzE4MTFkMWU1ZTIyMWExODcyMDM1MjU5ZjY2ZGM5ZThlYmZlMWZiZWQ5MjBlMjpwOlQ6Rg<https://protect.checkpoint.com/v2/r01/___https:/archive.midrange.com/midrange-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzo1NzYzNTYyYWIyMmUyOTViMDkxNTdiYjc0YTlhYTg4ODo3OmE1ZTY6YmEwMThiY2VlZjQzZThmMjcyNzE4MTFkMWU1ZTIyMWExODcyMDM1MjU5ZjY2ZGM5ZThlYmZlMWZiZWQ5MjBlMjpwOlQ6Rg>.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org<mailto:support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org> for any subscription related questions.

Greg Wilburn
Director of IT
301.895.3792 ext. 1231
-- 
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.