Having an issue with the STAT api and it reporting back "No such path or directory."
I am reading a directory and running STAT against each link that is found. I am using stat to determine if the link is a Folder or Stream file. If it is a folder I proceed to read through that. However when i attempt to run STAT against any links i find in the sub directory I am getting a "No such path or directory." error. Trying to determine what I am missing. This is working when reading the parent directory but not the sub directory. Do I need to do something like set current directory when I am reading the sub directory?
I am reading a directory and running STAT against each link that is found. I am using stat to determine if the link is a Folder or Stream file. If it is a folder I proceed to read through that. However when i attempt to run STAT against any links i find in the sub directory I am getting a "No such path or directory." error. Trying to determine what I am missing. This is working when reading the parent directory but not the sub directory. Do I need to do something like set current directory when I am reading the sub directory?
Code:
// ******************************************************************************************* // * Read Transfer Directory. // ******************************************************************************************* DCL-Proc Read_Transfer_Folder; Path1 = %TrimR(L10IfsPath) + %TrimR(L10IfsDirT); p_Dir1 = OpenDIR(Path1); If P_Dir1 <> *Null; p_DIREnt1 = ReadDIR(p_Dir1); Dow p_DIREnt1 <> *Null; Name = %SubST(DIREnt1.D_Name:1:DirEnt1.D_NameLen); If p_DIREnt1 <> *Null and Name <> '.' and Name <> '..' and StmF_is_a_Directory(Path1+'/'+Name); Read_Warehouse_Folder(); EndIF; p_DIREnt1 = ReadDIR(p_Dir1); EndDO; EndIF; CloseDIR(p_Dir1); Return; End-Proc Read_Transfer_Folder; // ******************************************************************************************* // * Read Data Directories // ******************************************************************************************* DCL-Proc Read_Warehouse_Folder; NM = Name; Dsply NM; Path2 = Path1 + '/' + Name; p_Dir2 = OpenDIR(Path2); If P_Dir2 <> *Null; p_DIREnt2 = ReadDIR(p_Dir2); Dow p_DIREnt2 <> *Null; Name = %SubST(DIREnt2.D_Name:1:DirEnt2.D_NameLen); If p_DIREnt2 <> *Null and Name <> '.' and Name <> '..' and StmF_is_a_Directory(Path1+'/'+Name); NM = Name; Dsply NM; EndIF; p_DIREnt2 = ReadDIR(p_Dir2); EndDO; EndIF; CloseDIR(p_Dir2); Return; End-Proc Read_Warehouse_Folder; // ******************************************************************************************* // * Check if Stream File is a Directory. // ******************************************************************************************* DCL-Proc StmF_is_a_Directory; DCL-PI StmF_is_a_Directory Ind; Path VarChar(1024) Const Options(*VarSize); End-PI; DCL-S MyStat Like(StatDS) Based(p_MyStat); DCL-S p_MyStat Pointer Inz; DCL-S StatSize Int(10) Inz; DCL-S Line Char(1024); // Get stat info into "MyStat" StatSize = %Size(MyStat); p_MyStat = %Alloc(StatSize); If LStat(Path:p_MyStat) < *Zero; Line = %str(strerror(errno)); Return *Off; EndIF; Return *On; End-Proc StmF_is_a_Directory;
Comment