| 43 | extern "C" FILE * fopen_compressed(const char* filename, const char* mode, bool* piped); |
| 44 | |
| 45 | BOOL 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 |
nothing calls this directly
no test coverage detected