Skip to content

Commit

Permalink
depressed: fix base path (opening)
Browse files Browse the repository at this point in the history
  • Loading branch information
plzombie committed Oct 27, 2024
1 parent d0e5ab2 commit a6144b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
9 changes: 8 additions & 1 deletion src/depressed_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,14 @@ namespace Depressed {
}
} else if(read == ERead::PAGES) {
if(wcscmp(value, L"Page") == 0) {
CPage *page = new CPage();
CPage *page;

try {
page = new CPage();
} catch (std::bad_alloc) {
success = false;
break;
}

page->Create();

Expand Down
6 changes: 3 additions & 3 deletions src/depressed_open.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ namespace Depressed {
IXmlWriter *writer;
IStream *filestream;

dirptr = wcschr(filename, '/');
dirptr = wcsrchr(filename, '/');
if(dirptr) {
wchar_t *dirptr2;

dirptr2 = wcschr(dirptr, '\\');
dirptr2 = wcsrchr(dirptr, '\\');
if(dirptr2)
dirptr = dirptr2;
} else
dirptr = wcschr(filename, '\\');
dirptr = wcsrchr(filename, '\\');
if(dirptr) {
size_t len;

Expand Down
16 changes: 9 additions & 7 deletions src/depressed_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@ namespace Depressed {
hr = writer->WriteString(m_filename);
else {
size_t basepath_len;
wchar_t *filename;
wchar_t *filename = m_filename;

basepath_len = wcslen(basepath);
filename = m_filename + basepath_len;
while(*filename) {
if(*filename == '\\' || *filename == '/')
filename++;
else
break;
if(wcsncmp(basepath, filename, basepath_len) == 0) {
filename += basepath_len;
while(*filename) {
if(*filename == '\\' || *filename == '/')
filename++;
else
break;
}
}

hr = writer->WriteString(filename);
Expand Down

0 comments on commit a6144b2

Please sign in to comment.