Class: File#

A system which provides the ability to read and write files. There are no standard IO natives so this system relies on an exploit which ended up being sanctioned by Blizzard, and because of this there are some caveats.

  • All files are confined to the Documents\Warcraft III\CustomMapData folder.
  • The only allowed file extensions are .txt and .pld.
  • Generated files contain boilerplate JASS code.
  • You cannot delete files but you can empty their contents.

example

// Write to the file
File.write("data.txt", "Hello world!");
// Read it's contents
const contents = File.read("data.txt");
// Display the contents
if (contents) {
print(contents);
}

Hierarchy#

  • File

Methods#

read#

static read(filename: string): undefined | string

Read text from a file inside of the CustomMapData folder.

Parameters:#

NameTypeDescription
filenamestringThe name of the file to read.

Returns: undefined | string

Returns undefined when the file could not be read.

Defined in: system/file.ts:65


write#

static write(filename: string, contents: string): File

Write text to a file inside. All files are placed within the CustomMapData folder.

Parameters:#

NameTypeDescription
filenamestringThe name of the file to write to. Supported extensions are .txt and .pld.
contentsstringThe contents to write to the file.

Returns: File

Defined in: system/file.ts:108


writeRaw#

static writeRaw(filename: string, contents: string, allowReading?: boolean): File

Write text to a file with the option to not include boilerplate for reading the file back.

Parameters:#

NameTypeDefault valueDescription
filenamestring-The name of the file to write to. Supported extensions are .txt and .pld.
contentsstring-The contents to write to the file.
allowReadingbooleanfalseIf set to true, boilerplate code will be included for reading the file with File.read.

Returns: File

Defined in: system/file.ts:81