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

Function assertValidTarStreamOptions

tar/tar_stream.ts:520–593  ·  view source on GitHub ↗
(options: TarStreamOptions)

Source from the content-addressed store, hash-verified

518 * ```
519 */
520export function assertValidTarStreamOptions(options: TarStreamOptions): void {
521 if (
522 options.mode != undefined &&
523 (Number.isNaN(options.mode) ||
524 options.mode < 0 ||
525 octalLength(options.mode) > 6)
526 ) {
527 throw new TypeError(
528 "Cannot add to the tar archive: Invalid Mode provided",
529 );
530 }
531 if (
532 options.uid != undefined &&
533 (Number.isNaN(options.uid) ||
534 options.uid < 0 ||
535 octalLength(options.uid) > 6)
536 ) {
537 throw new TypeError(
538 "Cannot add to the tar archive: Invalid UID provided",
539 );
540 }
541 if (
542 options.gid != undefined &&
543 (Number.isNaN(options.gid) ||
544 options.gid < 0 ||
545 octalLength(options.gid) > 6)
546 ) {
547 throw new TypeError("Cannot add to the tar archive: Invalid GID provided");
548 }
549 if (
550 options.mtime != undefined &&
551 (Number.isNaN(options.mtime) ||
552 options.mtime < 0 ||
553 octalLength(options.mtime) > 11)
554 ) {
555 throw new TypeError(
556 "Cannot add to the tar archive: Invalid MTime provided",
557 );
558 }
559 if (
560 options.uname &&
561 // deno-lint-ignore no-control-regex
562 (options.uname.length > 32 - 1 || !/^[\x00-\x7F]*$/.test(options.uname))
563 ) {
564 throw new TypeError(
565 "Cannot add to the tar archive: Invalid UName provided",
566 );
567 }
568 if (
569 options.gname &&
570 // deno-lint-ignore no-control-regex
571 (options.gname.length > 32 - 1 || !/^[\x00-\x7F]*$/.test(options.gname))
572 ) {
573 throw new TypeError(
574 "Cannot add to the tar archive: Invalid GName provided",
575 );
576 }
577 if (

Callers 2

tar_stream_test.tsFile · 0.90
#parseHeaderIntoMethod · 0.85

Calls 1

octalLengthFunction · 0.85

Tested by

no test coverage detected