Commit 37bd7caa authored by svatal's avatar svatal Committed by GitHub

feat(typedefs): readdir, stat, readFile (#74)

+ readdir() with stats:true option
+ added stat() command
+ cleared readFile() return type
parent 126fa009
...@@ -32,6 +32,27 @@ interface SMB2Readable extends Readable { ...@@ -32,6 +32,27 @@ interface SMB2Readable extends Readable {
interface SMB2Writable extends Writable {} interface SMB2Writable extends Writable {}
interface IEncodingOption {
encoding?: string | null;
}
interface IStatsOption {
stats: true;
}
interface IStats {
name: string,
birthtime: Date,
mtime: Date,
atime: Date,
ctime: Date,
isDirectory(): boolean
}
interface IFileStats extends IStats {
name: string,
}
declare class SMB2 { declare class SMB2 {
constructor(options: ISMB2Options); constructor(options: ISMB2Options);
disconnect(): void; disconnect(): void;
...@@ -42,21 +63,36 @@ declare class SMB2 { ...@@ -42,21 +63,36 @@ declare class SMB2 {
mkdir(path: string, mode: number, cb: (err?: Error) => void): void; mkdir(path: string, mode: number, cb: (err?: Error) => void): void;
mkdir(path: string, cb: (err?: Error) => void): void; mkdir(path: string, cb: (err?: Error) => void): void;
readdir(path: string): Promise<string[]>; readdir(path: string, options?: IEncodingOption): Promise<string[]>;
readdir(path: string, options: IEncodingOption & IStatsOption): Promise<IFileStats[]>;
readdir(path: string, cb: (err?: Error, files?: string[]) => void): void; readdir(path: string, cb: (err?: Error, files?: string[]) => void): void;
readdir(path: string, options: IEncodingOption, cb: (err?: Error, files?: string[]) => void): void;
readdir(path: string, options: IEncodingOption & IStatsOption, cb: (err?: Error, files?: IFileStats[]) => void): void;
stat(path: string): Promise<IStats>;
stat(path: string, cb: (err?: Error, stats?: IStats) => void): void;
readFile( readFile(
path: string, path: string,
options?: { encoding: string | null } options?: { encoding?: null }
): Promise<Buffer | string>; ): Promise<Buffer>;
readFile(
path: string,
options: { encoding: string }
): Promise<string>;
readFile(
path: string,
cb: (err?: Error, content?: Buffer) => void
): void;
readFile( readFile(
path: string, path: string,
cb: (err?: Error, content?: Buffer | string) => void options: { encoding?: null },
cb: (err?: Error, content?: Buffer) => void
): void; ): void;
readFile( readFile(
path: string, path: string,
options: { encoding: string | null }, options: { encoding: string },
cb: (err?: Error, content?: Buffer | string) => void cb: (err?: Error, content?: string) => void
): void; ): void;
rename( rename(
...@@ -81,7 +117,7 @@ declare class SMB2 { ...@@ -81,7 +117,7 @@ declare class SMB2 {
writeFile( writeFile(
path: string, path: string,
data: string | Buffer, data: string | Buffer,
options?: { encoding: string | null } options?: IEncodingOption
): Promise<void>; ): Promise<void>;
writeFile( writeFile(
path: string, path: string,
...@@ -91,7 +127,7 @@ declare class SMB2 { ...@@ -91,7 +127,7 @@ declare class SMB2 {
writeFile( writeFile(
path: string, path: string,
data: string | Buffer, data: string | Buffer,
options: { encoding: string | null }, options: IEncodingOption,
cb: (err?: Error) => void cb: (err?: Error) => void
): void; ): void;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment