forked from alicevision/AliceVision
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticVector.cpp
More file actions
40 lines (34 loc) · 1.06 KB
/
StaticVector.cpp
File metadata and controls
40 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This file is part of the AliceVision project.
// Copyright (c) 2017 AliceVision contributors.
// This Source Code Form is subject to the terms of the Mozilla Public License,
// v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
#include "StaticVector.hpp"
#include <cstdio>
namespace aliceVision {
int getArrayLengthFromFile(std::string fileName)
{
FILE* f = fopen(fileName.c_str(), "rb");
if(f == nullptr)
{
// printf("WARNING: file %s does not exists!\n", fileName.c_str());
return 0;
}
int n = 0;
size_t retval = fread(&n, sizeof(int), 1, f);
if( retval != sizeof(int) )
{
ALICEVISION_LOG_WARNING("[IO] getArrayLengthFromFile: can't read array length (1)");
}
if(n == -1)
{
retval = fread(&n, sizeof(int), 1, f);
if( retval != sizeof(int) )
{
ALICEVISION_LOG_WARNING("[IO] getArrayLengthFromFile: can't read array length (2)");
}
}
fclose(f);
return n;
}
} // namespace aliceVision