Skip to content

Commit

Permalink
fix bug and add debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Mar 14, 2024
1 parent 25ddd45 commit e2b0579
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/algo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,14 @@ void testshanten(){
}

int Access(const char *filename, int mode){
return access((Header::datafolderprefix + filename).c_str(), mode);
std::string full_filename = Header::datafolderprefix + filename;
#ifdef __APPLE__
// 如果是访问data,apple需要重设路径到Header::appledatafolderprefix
if (filename.find("data/") == 0)
full_filename = Header::appledatafolderprefix + filename;
#endif
std::cout << "Access " << full_filename << '\n';
return access(full_filename.c_str(), mode);
}

CJsonObject ReadJSON(const std::string &filename){
Expand All @@ -345,6 +352,7 @@ CJsonObject ReadJSON(const std::string &filename){
if (filename.find("data/") == 0)
full_filename = Header::appledatafolderprefix + filename;
#endif
std::cout << "ReadJSON " << full_filename << '\n';
auto f = fopen(full_filename.c_str(), "r");
for (; ; ){
int length = fread(buffer, 1, JSONBUFFERSIZE - 1, f);
Expand Down

0 comments on commit e2b0579

Please sign in to comment.