MCPcopy Index your code
hub / github.com/nodejs/node / writeFile

Function writeFile

deps/v8/tools/include-file-as-bytes.py:34–54  ·  view source on GitHub ↗
(src_path, dst_path, name)

Source from the content-addressed store, hash-verified

32
33
34def writeFile(src_path, dst_path, name):
35 assert os.path.exists(src_path)
36
37 with open(dst_path, 'w') as dst:
38 dst.write(HEADER.format(name))
39 with open(src_path, 'rb') as src:
40 # We wish to read unsigned ints
41 s = struct.Struct('@I')
42 assert s.size == 4
43 mm = mmap.mmap(src.fileno(), 0, access=mmap.ACCESS_READ)
44 assert len(mm) % s.size == 0
45
46 # We want to have 16 values per line
47 for offset in range(0, len(mm), s.size):
48 u32 = s.unpack_from(mm, offset)[0]
49 if offset % 16 == 0:
50 dst.write("\n ")
51 dst.write(" 0x{:08x},".format(u32))
52
53 dst.write(FOOTER.format(name, int(len(mm) / s.size)))
54 mm.close()
55
56
57if __name__ == '__main__':

Callers 6

reifyFinishFunction · 0.50
editMethod · 0.50
execMethod · 0.50
updateNotifierFunction · 0.50
saveSnapshotsMethod · 0.50

Calls 7

intFunction · 0.85
formatMethod · 0.65
closeMethod · 0.65
openFunction · 0.50
rangeFunction · 0.50
existsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…