MCPcopy Create free account
hub / github.com/denoland/std / openSync

Function openSync

fs/unstable_open.ts:172–202  ·  view source on GitHub ↗
(path: string | URL, options?: OpenOptions)

Source from the content-addressed store, hash-verified

170 * @returns A {@linkcode FsFile} instance.
171 */
172export function openSync(path: string | URL, options?: OpenOptions): FsFile {
173 if (isDeno) {
174 return Deno.openSync(path, options);
175 } else {
176 const {
177 read = true,
178 write = false,
179 append = false,
180 truncate = false,
181 create = false,
182 createNew = false,
183 mode = 0o666,
184 } = options ?? {};
185
186 try {
187 const flag = getOpenFsFlag({
188 read,
189 write,
190 append,
191 truncate,
192 create,
193 createNew,
194 });
195
196 const fd = getNodeFs().openSync(path, flag, mode);
197 return new NodeFsFile(fd) as FsFile;
198 } catch (error) {
199 throw mapError(error);
200 }
201 }
202}

Callers 7

createSyncFunction · 0.90

Calls 3

getOpenFsFlagFunction · 0.90
getNodeFsFunction · 0.90
mapErrorFunction · 0.90

Tested by

no test coverage detected