| 80 | }; |
| 81 | |
| 82 | BOOL LASreaderBIN::open(const char* file_name) |
| 83 | { |
| 84 | if (file_name == 0) |
| 85 | { |
| 86 | laserror("file name pointer is zero"); |
| 87 | return FALSE; |
| 88 | } |
| 89 | |
| 90 | // open file |
| 91 | file = LASfopen(file_name, "rb"); |
| 92 | if (file == 0) |
| 93 | { |
| 94 | laserror("cannot open file '%s'", file_name); |
| 95 | return FALSE; |
| 96 | } |
| 97 | |
| 98 | if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) |
| 99 | { |
| 100 | LASMessage(LAS_WARNING, "setvbuf() failed with buffer size %d", 2*LAS_TOOLS_IO_IBUFFER_SIZE); |
| 101 | } |
| 102 | |
| 103 | // create input stream |
| 104 | |
| 105 | ByteStreamIn* in; |
| 106 | if (Endian::IS_LITTLE_ENDIAN) |
| 107 | in = new ByteStreamInFileLE(file); |
| 108 | else |
| 109 | in = new ByteStreamInFileBE(file); |
| 110 | |
| 111 | // clean header |
| 112 | |
| 113 | header.clean(); |
| 114 | |
| 115 | // maybe set creation date |
| 116 | |
| 117 | #ifdef _WIN32 |
| 118 | WIN32_FILE_ATTRIBUTE_DATA attr; |
| 119 | SYSTEMTIME creation; |
| 120 | GetFileAttributesEx(file_name, GetFileExInfoStandard, &attr); |
| 121 | FileTimeToSystemTime(&attr.ftCreationTime, &creation); |
| 122 | int startday[13] = {-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; |
| 123 | header.file_creation_day = startday[creation.wMonth] + creation.wDay; |
| 124 | header.file_creation_year = creation.wYear; |
| 125 | // leap year handling |
| 126 | if ((((creation.wYear)%4) == 0) && (creation.wMonth > 2)) header.file_creation_day++; |
| 127 | #else |
| 128 | header.file_creation_day = 333; |
| 129 | header.file_creation_year = 2011; |
| 130 | #endif |
| 131 | |
| 132 | return open(in); |
| 133 | } |
| 134 | |
| 135 | BOOL LASreaderBIN::open(ByteStreamIn* stream) |
| 136 | { |
nothing calls this directly
no test coverage detected