Show file mode on file listing, add ability to change file mode
This commit is contained in:
parent
8611ebb2d6
commit
ed5613e207
9 changed files with 150 additions and 11 deletions
|
@ -20,3 +20,33 @@ export const randomInt = (low: number, high: number) => Math.floor(Math.random()
|
|||
export const cleanDirectoryPath = (path: string) => path.replace(/(^#\/*)|(\/(\/*))|(^$)/g, '/');
|
||||
|
||||
export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
|
||||
|
||||
export function fileBitsToString (mode: string, directory: boolean): string {
|
||||
const m = parseInt(mode, 8);
|
||||
|
||||
let buf = '';
|
||||
'dalTLDpSugct?'.split('').forEach((c, i) => {
|
||||
if ((m & (1 << (32 - 1 - i))) !== 0) {
|
||||
buf = buf + c;
|
||||
}
|
||||
});
|
||||
|
||||
if (buf.length === 0) {
|
||||
// If the file is directory, make sure it has the directory flag.
|
||||
if (directory) {
|
||||
buf = 'd';
|
||||
} else {
|
||||
buf = '-';
|
||||
}
|
||||
}
|
||||
|
||||
'rwxrwxrwx'.split('').forEach((c, i) => {
|
||||
if ((m & (1 << (9 - 1 - i))) !== 0) {
|
||||
buf = buf + c;
|
||||
} else {
|
||||
buf = buf + '-';
|
||||
}
|
||||
});
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue