Header menu logo issie

FilesIO Module

Types

Type Description

LoadStatus

Functions and values

Function or value Description

askForExistingProjectPath defaultPath

Full Usage: askForExistingProjectPath defaultPath

Parameters:
    defaultPath : string option

Returns: string option

Ask the user to choose a project file, with a dialog window. Return the folder containing the chosen project file. Return None if the user exits withouth selecting a path.

defaultPath : string option
Returns: string option

askForExistingSheetPaths defaultPath

Full Usage: askForExistingSheetPaths defaultPath

Parameters:
    defaultPath : string option

Returns: string list option

ask for existing sheet paths

defaultPath : string option
Returns: string list option

askForNewFile projectPath

Full Usage: askForNewFile projectPath

Parameters:
    projectPath : string

Returns: string option

Ask the user a new project path, with a dialog window. Return None if the user exits withouth selecting a path.

projectPath : string
Returns: string option

askForNewProjectPath defaultPath

Full Usage: askForNewProjectPath defaultPath

Parameters:
    defaultPath : string option

Returns: string option

Ask the user a new project path, with a dialog window. Return None if the user exits withouth selecting a path.

defaultPath : string option
Returns: string option

backupFileData path baseName

Full Usage: backupFileData path baseName

Parameters:
    path : string
    baseName : string

Returns: (int option * string) list

returns the list of backup files in descending chronological order.

path : string
baseName : string
Returns: (int option * string) list

baseName filePath

Full Usage: baseName filePath

Parameters:
    filePath : string

Returns: string
filePath : string
Returns: string

baseNameWithoutExtension

Full Usage: baseNameWithoutExtension

Returns: string -> string
Returns: string -> string

checkMemoryContents projectPath comp

Full Usage: checkMemoryContents projectPath comp

Parameters:
Returns: Component

If the component is a RAM update its contents based on its initialiser

projectPath : string
comp : Component
Returns: Component

copyFile sourcePath newPath

Full Usage: copyFile sourcePath newPath

Parameters:
    sourcePath : string
    newPath : string

copy a sheet from some source path to a destination path

sourcePath : string
newPath : string

createEmptyDgmFile folderPath baseName

Full Usage: createEmptyDgmFile folderPath baseName

Parameters:
    folderPath : string
    baseName : string

Returns: Result<unit, string>

Create new empty diagram file. Automatically add the .dgm suffix.

folderPath : string
baseName : string
Returns: Result<unit, string>

dirName filePath

Full Usage: dirName filePath

Parameters:
    filePath : string

Returns: string
filePath : string
Returns: string

ensureDirectory dPath

Full Usage: ensureDirectory dPath

Parameters:
    dPath : string

dPath : string

exists filePath

Full Usage: exists filePath

Parameters:
    filePath : string

Returns: bool
filePath : string
Returns: bool

extName filePath

Full Usage: extName filePath

Parameters:
    filePath : string

Returns: string
filePath : string
Returns: string

fileExistsWithExtn extn folderPath baseName

Full Usage: fileExistsWithExtn extn folderPath baseName

Parameters:
    extn : string
    folderPath : string
    baseName : string

Returns: bool
extn : string
folderPath : string
baseName : string
Returns: bool

fileNameIsBad name

Full Usage: fileNameIsBad name

Parameters:
    name : char seq

Returns: bool
name : char seq
Returns: bool

filePathIsBad

Full Usage: filePathIsBad

Returns: string -> bool
Returns: string -> bool

getBaseNameNoExtension filePath

Full Usage: getBaseNameNoExtension filePath

Parameters:
    filePath : string

Returns: string
filePath : string
Returns: string

getCWD u

Full Usage: getCWD u

Parameters:
    u : unit

Returns: string
u : unit
Returns: string

getLatestCanvas state

Full Usage: getLatestCanvas state

Parameters:
Returns: Component list * Connection list

Interface function that can read old-style circuits (without wire vertices) as well as new circuits with vertices. Old circuits have an expansion parameter since new symbols are larger (in units) than old ones.

state : SavedInfo
Returns: Component list * Connection list

getLatestComp comp

Full Usage: getLatestComp comp

Parameters:
Returns: Component

Update from old component types to new In addition do some sanity checks The standard way to add functionality to an existing component is to create a new component type, keeping the old type. Then on reading sheets from disk both new and old will be correctly read. This function will be called on load and will convert from the old type to the new one so that the rest of issie need only process new types, but compatibility with saved old types remains.

comp : Component
Returns: Component

hasExtn extn fName

Full Usage: hasExtn extn fName

Parameters:
    extn : string
    fName : string

Returns: bool
extn : string
fName : string
Returns: bool

initialiseMem mem projectPath

Full Usage: initialiseMem mem projectPath

Parameters:
    mem : Memory1
    projectPath : string

Returns: Result<Memory1, string>

Return data for memory if it is linked to a ram. Return mem data if it is unlinked Error if the read fails ot the file parse fails.

mem : Memory1
projectPath : string
Returns: Result<Memory1, string>

jsonStringToMem jsonString

Full Usage: jsonStringToMem jsonString

Parameters:
    jsonString : string

Returns: Result<Map<bigint, bigint>, string>
jsonString : string
Returns: Result<Map<bigint, bigint>, string>

latestBackupFileData path baseName

Full Usage: latestBackupFileData path baseName

Parameters:
    path : string
    baseName : string

Returns: (int * string) option

returns the sequence number and name of the most recent (highest sequence number) backup file

path : string
baseName : string
Returns: (int * string) option

loadAllComponentFiles folderPath

Full Usage: loadAllComponentFiles folderPath

Parameters:
    folderPath : string

Returns: Result<LoadStatus list, string>

load all files in folderpath. Return Ok list of LoadStatus or a single Error.

folderPath : string
Returns: Result<LoadStatus list, string>

magnifySheet magnification comp

Full Usage: magnifySheet magnification comp

Parameters:
Returns: LegacyComponent
magnification : float
comp : LegacyComponent
Returns: LegacyComponent

makeData aWidth dWidth makeFun

Full Usage: makeData aWidth dWidth makeFun

Parameters:
    aWidth : int
    dWidth : int
    makeFun : int -> int -> bigint

Returns: Map<bigint, bigint>
aWidth : int
dWidth : int
makeFun : int -> int -> bigint
Returns: Map<bigint, bigint>

makeFixedROM addr data mem

Full Usage: makeFixedROM addr data mem

Parameters:
    addr : int
    data : int
    mem : Memory1

Returns: Result<Map<bigint, bigint>, 'a>
addr : int
data : int
mem : Memory1
Returns: Result<Map<bigint, bigint>, 'a>

makeLoadedComponentFromCanvasData (arg1, arg2) filePath timeStamp waveInfo sheetInfo

Full Usage: makeLoadedComponentFromCanvasData (arg1, arg2) filePath timeStamp waveInfo sheetInfo

Parameters:
Returns: LoadedComponent * Component list

load a component from its canvas and other elements

arg0 : Component list
arg1 : Connection list
filePath : string
timeStamp : DateTime
waveInfo : SavedWaveInfo option
sheetInfo : SheetInfo option
Returns: LoadedComponent * Component list

mkdir folderPath

Full Usage: mkdir folderPath

Parameters:
    folderPath : string

folderPath : string

openWriteDialogAndWriteMemory mem path

Full Usage: openWriteDialogAndWriteMemory mem path

Parameters:
Returns: string option
mem : Memory1
path : string
Returns: string option

pathJoin args

Full Usage: pathJoin args

Parameters:
    args : string[]

Returns: string
args : string[]
Returns: string

pathWithoutExtension filePath

Full Usage: pathWithoutExtension filePath

Parameters:
    filePath : string

Returns: string
filePath : string
Returns: string

readFile filePath

Full Usage: readFile filePath

Parameters:
    filePath : string

Returns: string
filePath : string
Returns: string

readFilesFromDirectory path

Full Usage: readFilesFromDirectory path

Parameters:
    path : string

Returns: string list

read file names from directory: returning [] on any error.

path : string
Returns: string list

readFilesFromDirectoryWithExtn path extn

Full Usage: readFilesFromDirectoryWithExtn path extn

Parameters:
    path : string
    extn : string

Returns: string list
path : string
extn : string
Returns: string list

readMemDefnLine addressWidth wordWidth lineNo s

Full Usage: readMemDefnLine addressWidth wordWidth lineNo s

Parameters:
    addressWidth : int
    wordWidth : int
    lineNo : int
    s : string

Returns: Result<(bigint * bigint), string>
addressWidth : int
wordWidth : int
lineNo : int
s : string
Returns: Result<(bigint * bigint), string>

readMemDefns addressWidth wordWidth fPath

Full Usage: readMemDefns addressWidth wordWidth fPath

Parameters:
    addressWidth : int
    wordWidth : int
    fPath : string

Returns: Result<Map<bigint, bigint>, string>
addressWidth : int
wordWidth : int
fPath : string
Returns: Result<Map<bigint, bigint>, string>

readMemLines addressWidth wordWidth lines

Full Usage: readMemLines addressWidth wordWidth lines

Parameters:
    addressWidth : int
    wordWidth : int
    lines : string array

Returns: Result<(bigint * bigint)[], string>
addressWidth : int
wordWidth : int
lines : string array
Returns: Result<(bigint * bigint)[], string>

readdir folderPath

Full Usage: readdir folderPath

Parameters:
    folderPath : string

Returns: string[]
folderPath : string
Returns: string[]

removeAutoFile folderPath baseName

Full Usage: removeAutoFile folderPath baseName

Parameters:
    folderPath : string
    baseName : string

folderPath : string
baseName : string

removeExtn extn fName

Full Usage: removeExtn extn fName

Parameters:
    extn : string
    fName : string

Returns: string option
extn : string
fName : string
Returns: string option

removeFile folderPath baseName

Full Usage: removeFile folderPath baseName

Parameters:
    folderPath : string
    baseName : string

folderPath : string
baseName : string

removeFileWithExtn extn folderPath baseName

Full Usage: removeFileWithExtn extn folderPath baseName

Parameters:
    extn : string
    folderPath : string
    baseName : string

Asyncronously remove file. ignore if file does not exist

extn : string
folderPath : string
baseName : string

rename oldPath newPath

Full Usage: rename oldPath newPath

Parameters:
    oldPath : string
    newPath : string

oldPath : string
newPath : string

renameFile extn folderPath baseName newBaseName

Full Usage: renameFile extn folderPath baseName newBaseName

Parameters:
    extn : string
    folderPath : string
    baseName : string
    newBaseName : string

Returns: Result<unit, string>
extn : string
folderPath : string
baseName : string
newBaseName : string
Returns: Result<unit, string>

saveAllProjectFilesFromLoadedComponentsToDisk proj

Full Usage: saveAllProjectFilesFromLoadedComponentsToDisk proj

Parameters:
proj : Project

savePngFile folderPath baseName png

Full Usage: savePngFile folderPath baseName png

Parameters:
    folderPath : string
    baseName : string
    png : string

Returns: Result<unit, string>

Save a PNG file (encoded base64, as from draw2d). Overwrite existing file if needed. Not used now we do not have Draw2D. Probably not useful but maybe one day could be used to print schematic?

folderPath : string
baseName : string
png : string
Returns: Result<unit, string>

saveStateToFile folderPath baseName (arg3, arg4, arg5)

Full Usage: saveStateToFile folderPath baseName (arg3, arg4, arg5)

Parameters:
Returns: Result<unit, string>

Save state to normal file. Automatically add the .dgm suffix. This version will not correctly deal with bigint numbers. See svaStateToFileNew

folderPath : string
baseName : string
arg2 : CanvasState
arg3 : SavedWaveInfo option
arg4 : SheetInfo option
Returns: Result<unit, string>

saveStateToFileExperimental folderPath baseName (arg3, arg4, arg5)

Full Usage: saveStateToFileExperimental folderPath baseName (arg3, arg4, arg5)

Parameters:
Returns: Result<unit, string>

Save state to file. Automatically add the .dgm suffix. This is the new version of the function that uses the new state format and copes with bigints However, it seems that it is not used??

folderPath : string
baseName : string
arg2 : CanvasState
arg3 : SavedWaveInfo option
arg4 : SheetInfo option
Returns: Result<unit, string>

staticDir ()

Full Usage: staticDir ()

Parameters:
    () : unit

Returns: string

This uses a fixed directory for production as a hack. it is dependent on the electron build which positions static assets there. productionbuild is defined in JSHelpers to be true for production (binary) builds only

() : unit
Returns: string

staticDirFromStatic ()

Full Usage: staticDirFromStatic ()

Parameters:
    () : unit

Returns: string

This will only work for development

() : unit
Returns: string

staticFileDirectory

Full Usage: staticFileDirectory

Returns: string

absolute path to repo directory ./static NB this path is not fixed (even as relative path) between production and dev builds, so this must be used to access static assets.

Returns: string

stripVertices conn

Full Usage: stripVertices conn

Parameters:
Returns: LegacyConnection
conn : LegacyConnection
Returns: LegacyConnection

tryCreateFolder path

Full Usage: tryCreateFolder path

Parameters:
    path : string

Returns: Result<unit, string>
path : string
Returns: Result<unit, string>

tryLoadComponentFromPath filePath

Full Usage: tryLoadComponentFromPath filePath

Parameters:
    filePath : string

Returns: Result<LoadedComponent, string>

Make a loadedComponent from the file read from filePath. Return the component, or an Error string.

filePath : string
Returns: Result<LoadedComponent, string>

tryReadFileSync fPath

Full Usage: tryReadFileSync fPath

Parameters:
    fPath : string

Returns: Result<string, string>
fPath : string
Returns: Result<string, string>

unlink folderPath

Full Usage: unlink folderPath

Parameters:
    folderPath : string

folderPath : string

writeFile path data

Full Usage: writeFile path data

Parameters:
    path : string
    data : string

Returns: Result<unit, string>

Write utf8 encoded data to file. Create file if it does not exist.

path : string
data : string
Returns: Result<unit, string>

writeMemDefns fPath mem

Full Usage: writeMemDefns fPath mem

Parameters:
Returns: Result<Result<unit, string>, string>
fPath : string
mem : Memory1
Returns: Result<Result<unit, string>, string>

Type something to start searching.