MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetPlatformStrings

Function GetPlatformStrings

tensorflow/core/platform/platform_strings.cc:26–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace tensorflow {
25
26int GetPlatformStrings(const std::string& path,
27 std::vector<std::string>* found) {
28 int result;
29 FILE* ifp = fopen(path.c_str(), "rb");
30 if (ifp != nullptr) {
31 static const char prefix[] = TF_PLAT_STR_MAGIC_PREFIX_;
32 int first_char = prefix[1];
33 int last_char = -1;
34 int c;
35 while ((c = getc(ifp)) != EOF) {
36 if (c == first_char && last_char == 0) {
37 int i = 2;
38 while (prefix[i] != 0 && (c = getc(ifp)) == prefix[i]) {
39 i++;
40 }
41 if (prefix[i] == 0) {
42 std::string str;
43 while ((c = getc(ifp)) != EOF && c != 0) {
44 str.push_back(c);
45 }
46 if (!str.empty()) {
47 found->push_back(str);
48 }
49 }
50 }
51 last_char = c;
52 }
53
54 result = (ferror(ifp) == 0) ? 0 : errno;
55 fclose(ifp);
56 } else {
57 result = errno;
58 }
59 return result;
60}
61
62} // namespace tensorflow

Callers 3

IsProbablySafeToLoadFunction · 0.85
PrintStringsFunction · 0.85
RunTestFunction · 0.85

Calls 4

c_strMethod · 0.80
fopenFunction · 0.50
push_backMethod · 0.45
emptyMethod · 0.45

Tested by 2

PrintStringsFunction · 0.68
RunTestFunction · 0.68