MCPcopy Create free account
hub / github.com/LAStools/LAStools / open

Method open

LASlib/src/lasreader_asc.cpp:45–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43extern "C" FILE * fopen_compressed(const char* filename, const char* mode, bool* piped);
44
45BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point)
46{
47 if (file_name == 0)
48 {
49 laserror("file name pointer is zero");
50 return FALSE;
51 }
52
53 clean();
54 this->comma_not_point = comma_not_point;
55
56 file = fopen_compressed(file_name, "r", &piped);
57 if (file == 0)
58 {
59 laserror("cannot open file '%s'", file_name);
60 return FALSE;
61 }
62
63 if (setvbuf(file, NULL, _IOFBF, 10 * LAS_TOOLS_IO_IBUFFER_SIZE) != 0)
64 {
65 LASMessage(LAS_WARNING, "setvbuf() failed with buffer size %d", 10 * LAS_TOOLS_IO_IBUFFER_SIZE);
66 }
67
68 // clean the header
69
70 header.clean();
71
72 // populate the header as much as it makes sense
73
74 snprintf(header.system_identifier, LAS_HEADER_CHAR_LEN, LAS_TOOLS_COPYRIGHT);
75 snprintf(header.generating_software, LAS_HEADER_CHAR_LEN, "via LASreaderASC (%d)", LAS_TOOLS_VERSION);
76
77 // maybe set creation date
78
79#ifdef _WIN32
80 WIN32_FILE_ATTRIBUTE_DATA attr;
81 SYSTEMTIME creation;
82 GetFileAttributesEx(file_name, GetFileExInfoStandard, &attr);
83 FileTimeToSystemTime(&attr.ftCreationTime, &creation);
84 int startday[13] = { -1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
85 header.file_creation_day = startday[creation.wMonth] + creation.wDay;
86 header.file_creation_year = creation.wYear;
87 // leap year handling
88 if ((((creation.wYear) % 4) == 0) && (creation.wMonth > 2)) header.file_creation_day++;
89#else
90 header.file_creation_day = 333;
91 header.file_creation_year = 2012;
92#endif
93
94 header.point_data_format = 0;
95 header.point_data_record_length = 20;
96
97 // initialize point
98
99 point.init(&header, header.point_data_format, header.point_data_record_length, &header);
100
101 // read header of ASC file
102

Callers

nothing calls this directly

Calls 11

laserrorFunction · 0.85
fopen_compressedFunction · 0.85
LASMessageFunction · 0.85
malloc_lasFunction · 0.85
sscanf_lasFunction · 0.85
set_offsetFunction · 0.85
get_payload_sizeMethod · 0.80
get_payloadMethod · 0.80
cleanFunction · 0.50
cleanMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected