Lines Matching refs:file

1593 function parse(file/*:RawBytes*/, options/*:CFBReadOpts*/)/*:CFBContainer*/ {  argument
1594 if(file[0] == 0x50 && file[1] == 0x4b) return parse_zip(file, options);
1595 if((file[0] | 0x20) == 0x6d && (file[1]|0x20) == 0x69) return parse_mad(file, options);
1596 if(file.length < 512) throw new Error("CFB file size " + file.length + " < 512");
1608 var blob/*:CFBlob*/ = /*::(*/file.slice(0,512)/*:: :any)*/;
1616 case 0: if(mv[1] == 0) return parse_zip(file, options);
1622 if(ssz !== 512) { blob = /*::(*/file.slice(0,ssz)/*:: :any)*/; prep_blob(blob, 28 /* blob.l */); }
1624 var header/*:RawBytes*/ = file.slice(0,ssz);
1663 /** Break the file up into sectors */
1664 var sectors/*:Array<RawBytes>*/ = sectorify(file, ssz);
1730 /** Break the file up into sectors */
1731 function sectorify(file/*:RawBytes*/, ssz/*:number*/)/*:Array<RawBytes>*/ { argument
1732 var nsectors = Math.ceil(file.length/ssz)-1;
1734 for(var i=1; i < nsectors; ++i) sectors[i-1] = file.slice(i*ssz,(i+1)*ssz);
1735 sectors[nsectors-1] = file.slice(nsectors*ssz);
1922 …case "file": /*:: if(typeof blob !== 'string') throw "Must pass a filename when type='file'"; */re…
1923 … !== 'string') throw "Must pass a base64-encoded binary string when type='file'"; */return parse(s…
1924 …case "binary": /*:: if(typeof blob !== 'string') throw "Must pass a binary string when type='file'…
2042 var file = cfb.FileIndex[i];
2043 if(!file.content) continue;
2044 var flen = file.content.length;
2100 var file/*:CFBEntry*/ = cfb.FileIndex[0];
2102 file = cfb.FileIndex[j];
2103 if(!file.content) continue;
2104 /*:: if(file.content == null) throw new Error("unreachable"); */
2105 flen = file.content.length;
2107 file.start = T;
2114 file = cfb.FileIndex[j];
2115 if(!file.content) continue;
2116 /*:: if(file.content == null) throw new Error("unreachable"); */
2117 flen = file.content.length;
2119 file.start = T;
2131 file = cfb.FileIndex[i];
2132 if(i === 0) file.start = file.size ? file.start - 1 : ENDOFCHAIN;
2133 var _nm/*:string*/ = (i === 0 && _opts.root) || file.name;
2141 o.write_shift(1, file.type);
2142 o.write_shift(1, file.color);
2143 o.write_shift(-4, file.L);
2144 o.write_shift(-4, file.R);
2145 o.write_shift(-4, file.C);
2146 if(!file.clsid) for(j = 0; j < 4; ++j) o.write_shift(4, 0);
2147 else o.write_shift(16, file.clsid, "hex");
2148 o.write_shift(4, file.state || 0);
2151 o.write_shift(4, file.start);
2152 o.write_shift(4, file.size); o.write_shift(4, 0);
2155 file = cfb.FileIndex[i];
2156 /*:: if(!file.content) throw new Error("unreachable"); */
2157 if(file.size >= 0x1000) {
2158 o.l = (file.start+1) << 9;
2159 if (has_buf && Buffer.isBuffer(file.content)) {
2160 file.content.copy(o, o.l, 0, file.size);
2162 o.l += (file.size + 511) & -512;
2164 for(j = 0; j < file.size; ++j) o.write_shift(1, file.content[j]);
2170 file = cfb.FileIndex[i];
2171 /*:: if(!file.content) throw new Error("unreachable"); */
2172 if(file.size > 0 && file.size < 0x1000) {
2173 if (has_buf && Buffer.isBuffer(file.content)) {
2174 file.content.copy(o, o.l, 0, file.size);
2176 o.l += (file.size + 63) & -64;
2178 for(j = 0; j < file.size; ++j) o.write_shift(1, file.content[j]);
2253 case "file": get_fs(); fs.writeFileSync(options.filename, (o/*:any*/)); return o;
2733 function parse_zip(file/*:RawBytes*/, options/*:CFBReadOpts*/)/*:CFBContainer*/ {
2734 var blob/*:CFBlob*/ = /*::(*/file/*:: :any)*/;
2759 /* trust local file header instead of CD entry */
2786 /* head starts just after local file header signature */
2788 /* [local file header] */
2819 /* [file data] */
2870 /* local file header */
2876 /* TODO: last mod file time/date */
2914 o.write_shift(4, 0); /* TODO: last mod file time/date */
3061 var file = cfb_add(cfb, fname.slice(root.length), fdata, {unsafe: true});
3062 if(ctype) file.ctype = ctype;
3065 function parse_mad(file/*:RawBytes*/, options/*:CFBReadOpts*/)/*:CFBContainer*/ {
3066 …if(a2s(file.slice(0,13)).toLowerCase() != "mime-version:") throw new Error("Unsupported MAD header…
3069 var data = (has_buf && Buffer.isBuffer(file) ? file.toString("binary") : a2s(file)).split("\r\n");
3076 row = row.slice(row.indexOf("file"));
3143 out.push('Content-Location: ' + (opts.root || 'file:///C:/SheetJS/') + fp);
3162 var file = !unsafe && CFB.find(cfb, name);
3163 if(!file) {
3170 file = ({name: filename(name), type: 2}/*:any*/);
3171 cfb.FileIndex.push(file);
3175 /*:: if(!file) throw new Error("unreachable"); */
3176 file.content = (content/*:any*/);
3177 file.size = content ? content.length : 0;
3179 if(opts.CLSID) file.clsid = opts.CLSID;
3180 if(opts.mt) file.mt = opts.mt;
3181 if(opts.ct) file.ct = opts.ct;
3183 return file;
3188 var file = CFB.find(cfb, name);
3189 if(file) for(var j = 0; j < cfb.FileIndex.length; ++j) if(cfb.FileIndex[j] == file) {
3199 var file = CFB.find(cfb, old_name);
3200 if(file) for(var j = 0; j < cfb.FileIndex.length; ++j) if(cfb.FileIndex[j] == file) {
3243 /* write or download file */
3290 throw new Error("cannot save file " + fname);
3293 /* read binary data from file */
3304 throw new Error("Cannot access file " + path);
3533 function safegetzipfile(zip, file/*:string*/) { argument
3535 var f = file.toLowerCase().replace(/[\/]/g, '\\'), g = f.replace(/\\/g,'\/');
3543 function getzipfile(zip, file/*:string*/) { argument
3544 var o = safegetzipfile(zip, file);
3545 if(o == null) throw new Error("Cannot find file " + file + " in zip");
3549 function getzipdata(zip, file/*:string*/, safe/*:?boolean*/)/*:any*/ { argument
3550 if(!safe) return getdata(getzipfile(zip, file));
3551 if(!file) return null;
3552 try { return getzipdata(zip, file); } catch(e) { return null; }
3555 function getzipstr(zip, file/*:string*/, safe/*:?boolean*/)/*:?string*/ { argument
3556 if(!safe) return getdatastr(getzipfile(zip, file));
3557 if(!file) return null;
3558 try { return getzipstr(zip, file); } catch(e) { return null; }
3561 function getzipbin(zip, file/*:string*/, safe/*:?boolean*/)/*:any*/ { argument
3562 if(!safe) return getdatabin(getzipfile(zip, file));
3563 if(!file) return null;
3564 try { return getzipbin(zip, file); } catch(e) { return null; }
3585 else zip.file(path, content);
3657 // TODO: CP remap (need to read file version to determine OS)
5454 function get_rels_path(file/*:string*/)/*:string*/ { argument
5455 var n = file.lastIndexOf("/");
5456 return file.slice(0,n+1) + '_rels/' + file.slice(n+1) + ".rels";
5520 case 'file-entry': // 4.3 <manifest:file-entry>
5536 …o.push(' <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="…
5537 …for(var i = 0; i < manifest.length; ++i) o.push(' <manifest:file-entry manifest:full-path="' + ma…
5543 function write_rdf_type(file/*:string*/, res/*:string*/, tag/*:?string*/) { argument
5545 ' <rdf:Description rdf:about="' + file + '">\n',
5550 function write_rdf_has(base/*:string*/, file/*:string*/) { argument
5553 …rt xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="' + file + '"/>\n',
6251 function parse_PropertySetStream(file, PIDSI, clsid) { argument
6252 var blob = file.content;
6509 …if((flags & 0x0002) && target.charAt(0) == "/" && target.charAt(1) != "/") target = "file://" + ta…
6519 if(Target.slice(0,7) == "file://") Target = Target.slice(7);
8752 …ngth >= 16 && d[14] == 0x05 && d[15] === 0x6c) throw new Error("Unsupported Works 3 for Mac file");
10188 throw new Error("ECMA-376 Encrypted file unrecognized Version: " + vers.Minor);
11694 /* [MS-XLS] 2.4.326 TODO: payload is a zip file */
17239 if(!data) throw new Error("Could not find file");
18388 /* FODS file root is <office:document> */
18390 /* UOS file root is <uof:UOF> */
18822 case "binary": case "buffer": case "file": return parse_xlml_xml(data, opts);
19836 …(_data=CFB.find(cfb, 'MN0')) && _data.content) throw new Error("Unsupported Works 4 for Mac file");
22506 case 'file-name': // 7.3.9
22620 if(!content) throw new Error("Missing content.xml in ODS / UOF file");
24153 throw new Error("Empty NUMBERS file");
24361 throw new Error("Template NUMBERS file must have exactly one sheet");
25048 ['bookFiles', false], /* include raw file structure (keys, files, cfb) */
25064 ['compression', false], /* Use file compression */
25138 …if(typeof Uint8Array == "undefined") throw new Error('NUMBERS file parsing requires Uint8Array sup…
25145 throw new Error('Unsupported NUMBERS file');
25148 if(safegetzipfile(zip, 'index.xml.gz')) throw new Error('Unsupported NUMBERS 08 file');
25149 if(safegetzipfile(zip, 'index.xml')) throw new Error('Unsupported NUMBERS 09 file');
25159 throw new Error('Unsupported ZIP file');
25331 …data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missi…
25336 …data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missi…
25339 throw new Error("ECMA-376 Encrypted file bad " + f);
25343 …data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missi…
25346 throw new Error("ECMA-376 Encrypted file bad " + f);
25350 …data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missi…
25355 …data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missi…
25360 …data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missi…
25738 …if(o.type == "file") { o.type = has_buf ? "buffer" : "binary"; d = read_binary(data); if(typeof Ui…
25771 case 0x08: if(n[1] === 0xE7) throw new Error("Unsupported Multiplan 1.x file!"); break;
25773 if(n[1] === 0xEC) throw new Error("Unsupported Multiplan 2.x file!");
25774 if(n[1] === 0xED) throw new Error("Unsupported Multiplan 3.x file!");
25782 var o = opts||{}; o.type = 'file';
25789 case "file": return write_dl(o.file, CFB.write(cfb, {type:has_buf ? 'buffer' : ""}));
25826 case "file": oopts.type = ftype; break;
25839 if(o.type === "file") return write_dl(o.file, out);
25856 case "file": return write_dl(opts.file, o, 'utf8');
25871 case "file": return write_dl(opts.file, out, 'binary');
25890 case "file": return write_dl(opts.file, out);
25960 var ext = o.file.slice(o.file.lastIndexOf(".")).toLowerCase();
25966 var o = opts||{}; o.type = 'file';
25967 o.file = filename;
25973 var o = opts||{}; o.type = 'file';
25974 o.file = filename;
25981 var o = opts||{}; o.type = 'file';
25982 o.file = filename;