MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / read_magic

Function read_magic

lite/example/cpp_example/npy.h:84–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84inline void read_magic(
85 std::istream& istream, unsigned char& v_major, unsigned char& v_minor) {
86 char buf[magic_string_length + 2];
87 istream.read(buf, magic_string_length + 2);
88
89 if (!istream) {
90 fprintf(stderr, "io error: failed reading file");
91 }
92
93 if (0 != std::memcmp(buf, magic_string, magic_string_length)) {
94 fprintf(stderr, "this file does not have a valid npy format.");
95 }
96
97 v_major = buf[magic_string_length];
98 v_minor = buf[magic_string_length + 1];
99}
100
101// typestring magic
102struct Typestring {

Callers 1

read_headerFunction · 0.70

Calls 1

readMethod · 0.45

Tested by

no test coverage detected