First draft of storage APIs (#122)
* First draft of storage APIs * bumped pxt-core * using fixed instances to seprate temp from permanent * send console to storage * sim support * missing sim stubs * adding storage blocks * more sim support * remove storage from default package * fix rendering of ms * render raw ms * slize at better place * duplicate bundled dir * refactor limit * simplify limit logic
This commit is contained in:
committed by
Peli de Halleux
parent
966fd81870
commit
20a4673f98
@ -8,6 +8,7 @@ namespace pxsim.MMapMethods {
|
||||
read?: (d: Buffer) => number;
|
||||
write?: (d: Buffer) => number;
|
||||
ioctl?: (id: number, d: Buffer) => number;
|
||||
lseek?: (offset: number, whence: number) => number;
|
||||
}
|
||||
|
||||
import BM = pxsim.BufferMethods
|
||||
@ -23,6 +24,7 @@ namespace pxsim.MMapMethods {
|
||||
if (!impl.read) impl.read = () => 0
|
||||
if (!impl.write) impl.write = () => 0
|
||||
if (!impl.ioctl) impl.ioctl = () => -1
|
||||
if (!impl.lseek) impl.lseek = (offset, whence) => -1
|
||||
}
|
||||
destroy() {
|
||||
}
|
||||
@ -68,6 +70,10 @@ namespace pxsim.MMapMethods {
|
||||
export function read(m: MMap, data: Buffer): number {
|
||||
return m.impl.read(data)
|
||||
}
|
||||
|
||||
export function lseek(m: MMap, offset: number, whence: number): number {
|
||||
return m.impl.lseek(offset, whence);
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.control {
|
||||
|
23
sim/state/storage.ts
Normal file
23
sim/state/storage.ts
Normal file
@ -0,0 +1,23 @@
|
||||
namespace pxsim.storage {
|
||||
export function __stringToBuffer(s: string): RefBuffer {
|
||||
// TODO
|
||||
return new RefBuffer(new Uint8Array([]));
|
||||
}
|
||||
|
||||
export function __bufferToString(b: RefBuffer): string {
|
||||
// TODO
|
||||
return "";
|
||||
}
|
||||
|
||||
export function __mkdir(fn: string) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
export function __unlink(filename: string): void {
|
||||
// TODO
|
||||
}
|
||||
|
||||
export function __truncate(filename: string): void {
|
||||
// TODO
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user