@@ -93,36 +93,43 @@ export class QSysFS implements vscode.FileSystemProvider {
9393
9494 async stat ( uri : vscode . Uri ) : Promise < vscode . FileStat > {
9595 const path = uri . path ;
96- const pathLength = path . split ( `/` ) . length ;
97- if ( pathLength > 5 || ! path . startsWith ( '/' ) ) {
96+ const pathParts = path . split ( `/` ) . filter ( Boolean ) ;
97+ if ( pathParts . length > 4 || ! path . startsWith ( '/' ) ) {
9898 throw new vscode . FileSystemError ( "Invalid member path" ) ;
9999 }
100- const type = pathLength > 3 ? vscode . FileType . File : vscode . FileType . Directory ;
100+
101+ let type = vscode . FileType . File ;
101102 const connection = instance . getConnection ( ) ;
102- if ( connection && type === vscode . FileType . File ) {
103- const member = parsePath ( path ) . name ;
104- const qsysPath = { ...Tools . parseQSysPath ( path ) , member } ;
105- const attributes = await this . getMemberAttributes ( connection , qsysPath ) ;
106- if ( attributes ) {
107- return {
108- ctime : Tools . parseAttrDate ( String ( attributes . CREATE_TIME ) ) ,
109- mtime : Tools . parseAttrDate ( String ( attributes . MODIFY_TIME ) ) ,
110- size : Number ( attributes . DATA_SIZE ) ,
111- type,
112- permissions : member && ! this . savedAsMembers . has ( uri . path ) ? getFilePermission ( uri ) : undefined
103+ if ( connection ) {
104+ const filePathLength = connection . getIAspDetail ( pathParts [ 0 ] ) ? 4 : 3 ;
105+ if ( pathParts . length < filePathLength ) {
106+ type = vscode . FileType . Directory ;
107+ }
108+
109+ if ( type === vscode . FileType . File ) {
110+ const member = parsePath ( path ) . name ;
111+ const qsysPath = { ...Tools . parseQSysPath ( path ) , member } ;
112+ const attributes = await this . getMemberAttributes ( connection , qsysPath ) ;
113+ if ( attributes ) {
114+ return {
115+ ctime : Tools . parseAttrDate ( String ( attributes . CREATE_TIME ) ) ,
116+ mtime : Tools . parseAttrDate ( String ( attributes . MODIFY_TIME ) ) ,
117+ size : Number ( attributes . DATA_SIZE ) ,
118+ type,
119+ permissions : member && ! this . savedAsMembers . has ( uri . path ) ? getFilePermission ( uri ) : undefined
120+ }
121+ } else {
122+ throw FileSystemError . FileNotFound ( uri ) ;
113123 }
114- } else {
115- throw FileSystemError . FileNotFound ( uri ) ;
116124 }
117125 }
118- else {
119- return {
120- ctime : 0 ,
121- mtime : 0 ,
122- size : 0 ,
123- type,
124- permissions : getFilePermission ( uri )
125- }
126+
127+ return {
128+ ctime : 0 ,
129+ mtime : 0 ,
130+ size : 0 ,
131+ type,
132+ permissions : getFilePermission ( uri )
126133 }
127134 }
128135
@@ -185,7 +192,7 @@ export class QSysFS implements vscode.FileSystemProvider {
185192 if ( connection && contentApi ) {
186193 let { asp, library, file, name : member , extension } = this . parseMemberPath ( connection , uri . path ) ;
187194 asp = asp || await connection . lookupLibraryIAsp ( library ) ;
188-
195+
189196 if ( ! content . length ) { //Coming from "Save as"
190197 const addMember = await connection . runCommand ( {
191198 command : `ADDPFM FILE(${ library } /${ file } ) MBR(${ member } ) SRCTYPE(${ extension || '*NONE' } )` ,
0 commit comments