Skip to content

Commit

Permalink
Move 'make file hidden' to eDocumentPath.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamv committed Nov 30, 2009
1 parent 9465ecb commit dcc2669
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
18 changes: 8 additions & 10 deletions src/ProjectInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "tinyxml.h"
#include "EasyPlistWriter.h"

#ifdef __WXMSW__
#include "eDocumentPath.h"
#endif

cxProjectInfo::cxProjectInfo(): isRoot(false), hasFilters(false) {};

cxProjectInfo::cxProjectInfo(const cxProjectInfo& info) {
Expand Down Expand Up @@ -70,9 +74,8 @@ static bool projectinfo_match(const wxString& path, const wxArrayString& include
}

for (unsigned int i = 0; i < excludes.GetCount(); ++i) {
if (wxMatchWild(excludes[i], path, false)) {
if (wxMatchWild(excludes[i], path, false))
return false;
}
}

return true;
Expand All @@ -86,7 +89,6 @@ bool cxProjectInfo::IsDirectoryIncluded(const wxString& dir_name) const {
return projectinfo_match(dir_name, includeDirs, excludeDirs);
}


bool cxProjectInfo::Load(const wxFileName& rootPath, const wxString& path, bool onlyFilters) {
wxFileName projectPath(path, wxEmptyString);
this->path = path;
Expand Down Expand Up @@ -140,9 +142,7 @@ bool cxProjectInfo::Load(const wxFileName& rootPath, const wxString& path, bool
const char* pattern = child->GetText();
if (pattern) filterArray->Add(wxString(pattern, wxConvUTF8));
}
else {
wxASSERT(false);
}
else wxASSERT(false);
}

filter = array; // jump over value
Expand All @@ -163,9 +163,8 @@ bool cxProjectInfo::Load(const wxFileName& rootPath, const wxString& path, bool
if (strcmp(val->Value(), "string") != 0) return false; // invalid dict
const char* value = val->GetText();

if (key) {
if (key)
this->env[wxString(key, wxConvUTF8)] = value ? wxString(value, wxConvUTF8) : *wxEmptyString;
}

env = val; // jump over value
}
Expand Down Expand Up @@ -246,7 +245,6 @@ void cxProjectInfo::Save(const wxString& rootPath) const {
eprj.Save(filepath);

#ifdef __WXMSW__
DWORD dwAttrs = ::GetFileAttributes(filepath.c_str());
::SetFileAttributes(filepath.c_str(), dwAttrs | FILE_ATTRIBUTE_HIDDEN);
eDocumentPath::MakeHidden(filepath);
#endif //__WXMSW__
}
16 changes: 11 additions & 5 deletions src/eDocumentPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ eDocumentPath::~eDocumentPath(void){}
bool eDocumentPath::MakeWritable(const wxString& path) {
#ifdef __WXMSW__
DWORD dwAttrs = ::GetFileAttributes(path);
if (dwAttrs & FILE_ATTRIBUTE_READONLY) {
dwAttrs &= ~FILE_ATTRIBUTE_READONLY;
return SetFileAttributes(path, dwAttrs) != 0;
}
else return true;
if (!(dwAttrs & FILE_ATTRIBUTE_READONLY)) return true;
dwAttrs &= ~FILE_ATTRIBUTE_READONLY;
return SetFileAttributes(path, dwAttrs) != 0;
#else
// Get protection
struct stat s;
Expand All @@ -29,6 +27,14 @@ bool eDocumentPath::MakeWritable(const wxString& path) {
#endif
}

#ifdef __WXMSW__
bool eDocumentPath::MakeHidden(const wxString& path) {
DWORD dwAttrs = ::GetFileAttributes(path);
if (dwAttrs & FILE_ATTRIBUTE_HIDDEN) return true;
return ::SetFileAttributes(path, dwAttrs | FILE_ATTRIBUTE_HIDDEN) != 0;
}
#endif

FILE_PERMISSIONS eDocumentPath::GetPermissions(const wxString& path) {
#ifdef __WXMSW__
return ::GetFileAttributes(path);
Expand Down
1 change: 1 addition & 0 deletions src/eDocumentPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class eDocumentPath
static bool SetPermissions(const wxString& path, FILE_PERMISSIONS permissions);

#ifdef __WXMSW__
static bool MakeHidden(const wxString& path);

static wxString GetCygwinDir();
static wxString GetCygdrivePrefix();
Expand Down

0 comments on commit dcc2669

Please sign in to comment.