|
10 | 10 |
|
11 | 11 | namespace nixfile {
|
12 | 12 |
|
13 |
| -void open(const extractor &input, infusor &output) |
14 |
| -{ |
15 |
| - std::string name = input.str(1); |
16 |
| - uint8_t omode = input.num<uint8_t>(2); |
17 |
| - nix::FileMode mode; |
18 |
| - |
19 |
| - switch (omode) { |
20 |
| - case 0: mode = nix::FileMode::ReadOnly; break; |
21 |
| - case 1: mode = nix::FileMode::ReadWrite; break; |
22 |
| - case 2: mode = nix::FileMode::Overwrite; break; |
23 |
| - default: throw std::invalid_argument("unkown open mode"); |
| 13 | + void open(const extractor &input, infusor &output) { |
| 14 | + std::string name = input.str(1); |
| 15 | + uint8_t omode = input.num<uint8_t>(2); |
| 16 | + nix::FileMode mode; |
| 17 | + |
| 18 | + switch (omode) { |
| 19 | + case 0: mode = nix::FileMode::ReadOnly; break; |
| 20 | + case 1: mode = nix::FileMode::ReadWrite; break; |
| 21 | + case 2: mode = nix::FileMode::Overwrite; break; |
| 22 | + default: throw std::invalid_argument("unkown open mode"); |
| 23 | + } |
| 24 | + |
| 25 | + nix::File fn = nix::File::open(name, mode); |
| 26 | + handle h = handle(fn); |
| 27 | + |
| 28 | + output.set(0, h); |
24 | 29 | }
|
25 | 30 |
|
26 |
| - nix::File fn = nix::File::open(name, mode); |
27 |
| - handle h = handle(fn); |
28 |
| - |
29 |
| - output.set(0, h); |
30 |
| -} |
31 |
| - |
32 |
| -mxArray *describe(const nix::File &fd) { |
33 |
| - struct_builder sb({ 1 }, { "format", "version", "location", "createdAt", "updatedAt" }); |
34 |
| - sb.set(fd.format()); |
35 |
| - sb.set(fd.version()); |
36 |
| - sb.set(fd.location()); |
37 |
| - sb.set(static_cast<uint64_t>(fd.createdAt())); |
38 |
| - sb.set(static_cast<uint64_t>(fd.updatedAt())); |
39 |
| - return sb.array(); |
40 |
| -} |
| 31 | + mxArray *describe(const nix::File &fd) { |
| 32 | + struct_builder sb({ 1 }, { "format", "version", "location", "createdAt", "updatedAt" }); |
| 33 | + sb.set(fd.format()); |
| 34 | + sb.set(fd.version()); |
| 35 | + sb.set(fd.location()); |
| 36 | + sb.set(static_cast<uint64_t>(fd.createdAt())); |
| 37 | + sb.set(static_cast<uint64_t>(fd.updatedAt())); |
| 38 | + return sb.array(); |
| 39 | + } |
41 | 40 |
|
42 | 41 | } // namespace nixfile
|
0 commit comments