Skip to content

Commit

Permalink
tagwriter option -p not working properly (taglib#1236)
Browse files Browse the repository at this point in the history
The -p option of tagwriter sample does not work.
This is because the picture file is open in text mode instead of binary.
Also, the isFile function does not work on Windows in 32 bit mode with
large files. Using _stat64 instead of stat solves the problem.
  • Loading branch information
ufleisch committed Jul 11, 2024
1 parent f3fb4d8 commit 84b45fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions examples/tagwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ bool isArgument(const char *s)

bool isFile(const char *s)
{
struct stat st;
#ifdef _WIN32
return ::stat(s, &st) == 0 && (st.st_mode & (S_IFREG));
struct _stat64 st;
return ::_stat64(s, &st) == 0 && (st.st_mode & S_IFREG);
#else
struct stat st;
return ::stat(s, &st) == 0 && (st.st_mode & (S_IFREG | S_IFLNK));
#endif
}
Expand Down Expand Up @@ -180,7 +181,7 @@ int main(int argc, char *argv[])
return 1;
}
ifstream picture;
picture.open(value.toCString());
picture.open(value.toCString(), ios::in | ios::binary);
stringstream buffer;
buffer << picture.rdbuf();
picture.close();
Expand Down

0 comments on commit 84b45fd

Please sign in to comment.