MCPcopy Create free account
hub / github.com/numpy/numpy / read_file

Function read_file

numpy/core/src/common/npy_cpuinfo_parser.h:95–123  ·  view source on GitHub ↗

* Read the content of /proc/cpuinfo into a user-provided buffer. * Return the length of the data, or -1 on error. Does *not* * zero-terminate the content. Will not read more * than 'buffsize' bytes. */

Source from the content-addressed store, hash-verified

93 * than 'buffsize' bytes.
94 */
95static int
96read_file(const char* pathname, char* buffer, size_t buffsize)
97{
98 int fd, count;
99
100 fd = open(pathname, O_RDONLY);
101 if (fd < 0) {
102 return -1;
103 }
104 count = 0;
105 while (count < (int)buffsize) {
106 int ret = read(fd, buffer + count, buffsize - count);
107 if (ret < 0) {
108 if (errno == EINTR) {
109 continue;
110 }
111 if (count == 0) {
112 count = -1;
113 }
114 break;
115 }
116 if (ret == 0) {
117 break;
118 }
119 count += ret;
120 }
121 close(fd);
122 return count;
123}
124
125/*
126 * Extract the content of a the first occurrence of a given field in

Callers 1

Calls 1

openFunction · 0.85

Tested by

no test coverage detected