Skip to content

Commit

Permalink
try to fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
supermihi committed Jan 24, 2024
1 parent b56a970 commit c6916ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/ctypes.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ cdef extern from 'taglib/audioproperties.h' namespace 'TagLib::AudioProperties':
Average = 1
Accurate = 2

cdef extern from 'taglib/tiostream.h' namespace 'TagLib':
ctypedef FileName

cdef extern from 'taglib/tfile.h' namespace 'TagLib':
cdef cppclass File:
AudioProperties *audioProperties()
Expand All @@ -67,19 +64,30 @@ cdef extern from 'taglib/tfile.h' namespace 'TagLib':
void removeUnsupportedProperties(StringList&)


cdef extern from 'taglib/tiostream.h' namespace 'TagLib':
IF UNAME_SYSNAME != "Windows":
ctypedef char* FileName
ELSE:
cdef cppclass FileName:
FileName(const char*)

cdef extern from 'taglib/fileref.h' namespace 'TagLib':
cdef cppclass FileRef:
FileRef(const char*, boolean, ReadStyle) except +
FileRef(FileName, boolean, ReadStyle) except +
File* file()

AudioProperties *audioProperties()
bint save() except +
PropertyMap properties()
PropertyMap setProperties(PropertyMap&)
void removeUnsupportedProperties(StringList&)
cdef inline FileRef* create_wrapper(unicode path) except +:
cdef FileName fn = path.encode('utf-8')
return new FileRef(fn, True, ReadStyle.Average)

cdef inline FileRef* create_wrapper(char* path) except +:
IF UNAME_SYSNAME != "Windows":
return new FileRef(path, True, ReadStyle.Average)
ELSE:
cdef FileName fn = FileName(path)
return new FileRef(fn, True, ReadStyle.Average)

cdef extern from 'taglib/taglib.h':
int TAGLIB_MAJOR_VERSION
Expand Down
2 changes: 1 addition & 1 deletion src/taglib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ cdef class File:
path = path.decode('utf-8')
path = Path(path)
self.path = path
self.cFile = ctypes.create_wrapper(str(path))
self.cFile = ctypes.create_wrapper(str(path).encode('utf-8'))
if self.cFile is NULL or self.cFile.file() is NULL or not self.cFile.file().isValid():
raise OSError(f'Could not read file {path}')

Expand Down

0 comments on commit c6916ae

Please sign in to comment.