aboutsummaryrefslogtreecommitdiff
path: root/src/systemLevelInformation.ts
diff options
context:
space:
mode:
authorPriyansh <[email protected]>2020-12-23 20:10:17 +0530
committerPriyansh <[email protected]>2020-12-23 20:10:17 +0530
commitb18cf71249b26d965215bcf06204daf6af5f55e7 (patch)
treec077bb09d95bb17e7cd9e863cfa793374d2e42a4 /src/systemLevelInformation.ts
parentad76cf4c73488ba871261959c2907fc7623a1460 (diff)
downloadstyx-b18cf71249b26d965215bcf06204daf6af5f55e7.tar.xz
styx-b18cf71249b26d965215bcf06204daf6af5f55e7.zip
Getting all files and folders of home directory
Diffstat (limited to 'src/systemLevelInformation.ts')
-rw-r--r--src/systemLevelInformation.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/systemLevelInformation.ts b/src/systemLevelInformation.ts
new file mode 100644
index 0000000..e902d32
--- /dev/null
+++ b/src/systemLevelInformation.ts
@@ -0,0 +1,33 @@
+import * as os from 'os';
+import * as glob from 'glob';
+import { statSync, readdirSync } from 'fs';
+import { extname, basename } from 'path';
+
+class systemLevelInformation {
+
+ getUserInfo(): { username: string, homedir: string } {
+ return {
+ username: os.userInfo().username,
+ homedir: os.userInfo().homedir
+ };
+ }
+
+ getAllFilesOfDirectory(currentDirectory): { files: string[], directories: string[] } {
+ const currentFilteredItems: string[] = readdirSync(currentDirectory).filter((item: string) => item.indexOf(".") !== 0);
+ const files: string[] = [];
+ const directories: string[] = [];
+
+ currentFilteredItems.forEach((item: string) => {
+ if (statSync(`${currentDirectory}/${item}`).isDirectory()) {
+ directories.push(item);
+ } else {
+ files.push(item);
+ }
+ });
+
+ return { files, directories };
+ }
+
+}
+
+export default new systemLevelInformation;