From f1611632b117f5fb91e495e21cbabe4c4b51e2c4 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml <66114686+Martin-Zeithaml@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:35:12 +0100 Subject: [PATCH] Use the zos function for getFileEncoding (#3642) * Use the zos function Signed-off-by: Martin Zeithaml * CCSID only for platform=zos Signed-off-by: Martin Zeithaml * Update type declaration file Signed-off-by: Martin Zeithaml --------- Signed-off-by: Martin Zeithaml Co-authored-by: Mark Ackert <35308966+MarkAckert@users.noreply.github.com> --- bin/libs/zos-fs.ts | 12 +++++++----- build/zwe/types/@qjstypes/zos.d.ts | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/libs/zos-fs.ts b/bin/libs/zos-fs.ts index 99305bc4b9..64eae0b2fd 100644 --- a/bin/libs/zos-fs.ts +++ b/bin/libs/zos-fs.ts @@ -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; } diff --git a/build/zwe/types/@qjstypes/zos.d.ts b/build/zwe/types/@qjstypes/zos.d.ts index ec41ae6571..551948c5c2 100644 --- a/build/zwe/types/@qjstypes/zos.d.ts +++ b/build/zwe/types/@qjstypes/zos.d.ts @@ -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;