mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 01:32:55 +02:00
MISC: Add file metadata (timestamps) (#2199)
This commit is contained in:
+7
-4
@@ -1,10 +1,10 @@
|
||||
import { BaseServer } from "./Server/BaseServer";
|
||||
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "./utils/JSONReviver";
|
||||
import { TextFilePath } from "./Paths/TextFilePath";
|
||||
import type { BaseServer } from "./Server/BaseServer";
|
||||
import { Generic_fromJSON, Generic_toJSON, type IReviverValue, constructorsForReviver } from "./utils/JSONReviver";
|
||||
import type { TextFilePath } from "./Paths/TextFilePath";
|
||||
import { ContentFile } from "./Paths/ContentFile";
|
||||
|
||||
/** Represents a plain text file that is typically stored on a server. */
|
||||
export class TextFile implements ContentFile {
|
||||
export class TextFile extends ContentFile {
|
||||
/** The full file name. */
|
||||
filename: TextFilePath;
|
||||
|
||||
@@ -13,13 +13,16 @@ export class TextFile implements ContentFile {
|
||||
|
||||
// Shared interface on Script and TextFile for accessing content
|
||||
get content() {
|
||||
this.metadata.read();
|
||||
return this.text;
|
||||
}
|
||||
set content(text: string) {
|
||||
this.metadata.edit();
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
constructor(filename = "default.txt" as TextFilePath, txt = "") {
|
||||
super();
|
||||
this.filename = filename;
|
||||
this.text = txt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user