Skip to content

Commit

Permalink
Use the zos function for getFileEncoding (#3642)
Browse files Browse the repository at this point in the history
* Use the zos function

Signed-off-by: Martin Zeithaml <[email protected]>

* CCSID only for platform=zos

Signed-off-by: Martin Zeithaml <[email protected]>

* Update type declaration file

Signed-off-by: Martin Zeithaml <[email protected]>

---------

Signed-off-by: Martin Zeithaml <[email protected]>
Co-authored-by: Mark Ackert <[email protected]>
  • Loading branch information
Martin-Zeithaml and MarkAckert authored Feb 14, 2024
1 parent 8bbb8bc commit d52a333
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bin/libs/zos-fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import * as shell from './shell';
// Get file encoding from z/OS USS tagging
export function getFileEncoding(filePath: string): number|undefined {
//zos.changeTag(file, id)
let returnArray = os.stat(filePath);
if (!returnArray[1] && ((returnArray[0].mode & os.S_IFREG) == os.S_IFREG)) { //no error, and is file
return returnArray[0].ccsid;
} else {
common.printError(`getFileEncoding path=${filePath}, err=${returnArray[1]}`);
if (os.platform == 'zos') {
let returnArray = zos.zstat(filePath);
if (!returnArray[1] && ((returnArray[0].mode & os.S_IFMT) == os.S_IFREG)) { //no error, and is file
return returnArray[0].ccsid;
} else {
common.printError(`getFileEncoding path=${filePath}, err=${returnArray[1]}`);
}
}
return undefined;
}
Expand Down
5 changes: 5 additions & 0 deletions build/zwe/types/@qjstypes/zos.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
export type ZStat = {
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blocks: number;
atime: number;
mtime: number;
ctime: number;
Expand Down

0 comments on commit d52a333

Please sign in to comment.