ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
StaticVector.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "StaticVector.h"
9 
10 #include <cstdio>
11 
12 namespace cloudViewer {
13 
14 int getArrayLengthFromFile(std::string fileName) {
15  FILE* f = fopen(fileName.c_str(), "rb");
16  if (f == nullptr) {
17  // printf("WARNING: file %s does not exists!\n", fileName.c_str());
18  return 0;
19  }
20 
21  int n = 0;
22  size_t retval = fread(&n, sizeof(int), 1, f);
23  if (retval != sizeof(int)) {
25  "[IO] getArrayLengthFromFile: can't read array length (1)");
26  }
27  if (n == -1) {
28  retval = fread(&n, sizeof(int), 1, f);
29  if (retval != sizeof(int)) {
31  "[IO] getArrayLengthFromFile: can't read array length (2)");
32  }
33  }
34  fclose(f);
35  return n;
36 }
37 
38 } // namespace cloudViewer
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
Generic file read and write utility for python interface.
int getArrayLengthFromFile(std::string fileName)