// close bool wxFile::Close() { if ( IsOpened() ) { if ( CheckForError(wxClose(m_fd)) ) { wxLogSysError(_("can't close file descriptor %d"), m_fd); m_fd = fd_invalid; return false; } else m_fd = fd_invalid; } return true; }
FitsFname::FitsFname(const wxString& path, bool create, bool clobber) { #ifdef __WINDOWS__ if (create) { if (!clobber && wxFileExists(path)) { m_str = new char[1]; *m_str = 0; return; } int fd = wxOpen(path, O_BINARY | O_WRONLY | O_CREAT, wxS_DEFAULT); wxClose(fd); } // use the short DOS 8.3 path name to avoid problems converting UTF-16 filenames to the ANSI filenames expected by CFITTSIO DWORD shortlen = GetShortPathNameW(path.wc_str(), 0, 0); if (shortlen) { LPWSTR shortpath = new WCHAR[shortlen]; GetShortPathNameW(path.wc_str(), shortpath, shortlen); int slen = WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, shortpath, shortlen, 0, 0, 0, 0); m_str = new char[slen + 1]; char *str = m_str; if (create) *str++ = '!'; WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, shortpath, shortlen, str, slen, 0, 0); delete[] shortpath; } else { m_str = new char[1]; *m_str = 0; } #else // __WINDOWS__ if (clobber) m_str = (wxT("!") + path).fn_str(); else m_str = path.fn_str(); #endif // __WINDOWS__ }