bool CTextFile::Open(const CPath& path, EOpenMode mode) { // wxFFile doesn't call close itself, but asserts instead. Close(); m_mode = mode; if (mode == read) { if (path.FileExists()) { m_file.Open(path.GetRaw(), wxT("r")); } } else if (mode == write) { m_file.Open(path.GetRaw(), wxT("w")); } else { wxFAIL; } return IsOpened(); }
TEST(CPath, DefaultConstructor) { CPath tmp; ASSERT_FALSE(tmp.IsOk()); ASSERT_EQUALS(tmp, CPath()); ASSERT_FALSE(tmp.FileExists()); ASSERT_FALSE(tmp.DirExists()); ASSERT_EQUALS(wxEmptyString, tmp.GetRaw()); ASSERT_EQUALS(wxEmptyString, tmp.GetPrintable()); ASSERT_EQUALS(CPath(), tmp.GetPath()); ASSERT_EQUALS(CPath(), tmp.GetFullName()); }