forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_llseek.c
More file actions
33 lines (28 loc) · 814 Bytes
/
test_llseek.c
File metadata and controls
33 lines (28 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright 2018 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*/
#include <emscripten/emscripten.h>
int main()
{
EM_ASM(
FS.writeFile('testfile', 'a=1\nb=2\n');
var stream = FS.open('testfile', 'a');
var fd = FS.write(stream, new Uint8Array([99, 61, 51]) /* c=3 */, 0, 3);
// check invalid whence
var ex;
try {
FS.llseek(stream, 0, 99);
} catch(e) {
ex = e;
}
assert(ex instanceof FS.ErrnoError && ex.errno === 28 /* EINVAL */);
if (FS.llseek(stream, 0, 1 /* SEEK_CUR */) === 11) {
console.log("success");
}
FS.close(stream);
);
return 0;
}