*/smbclient: use the new API with SMBCCTX parameter

As a side effect, the input plugin closes the SMB/CIFS connection
after closing the file.

This solves one part of
https://github.com/MusicPlayerDaemon/MPD/issues/916
This commit is contained in:
Max Kellermann
2020-07-20 21:10:58 +02:00
parent 697531a948
commit f6dc9bcad6
5 changed files with 93 additions and 42 deletions

View File

@@ -54,6 +54,46 @@ public:
* Throws on error.
*/
static SmbclientContext New();
SMBCFILE *Open(const char *fname, int flags, mode_t mode) noexcept {
return smbc_getFunctionOpen(ctx)(ctx, fname, flags, mode);
}
SMBCFILE *OpenReadOnly(const char *fname) noexcept {
return Open(fname, O_RDONLY, 0);
}
ssize_t Read(SMBCFILE *file, void *buf, size_t count) noexcept {
return smbc_getFunctionRead(ctx)(ctx, file, buf, count);
}
off_t Seek(SMBCFILE *file, off_t offset, int whence=SEEK_SET) noexcept {
return smbc_getFunctionLseek(ctx)(ctx, file, offset, whence);
}
int Stat(const char *fname, struct stat &st) noexcept {
return smbc_getFunctionStat(ctx)(ctx, fname, &st);
}
int Stat(SMBCFILE *file, struct stat &st) noexcept {
return smbc_getFunctionFstat(ctx)(ctx, file, &st);
}
void Close(SMBCFILE *file) noexcept {
smbc_getFunctionClose(ctx)(ctx, file);
}
SMBCFILE *OpenDirectory(const char *fname) noexcept {
return smbc_getFunctionOpendir(ctx)(ctx, fname);
}
void CloseDirectory(SMBCFILE *dir) noexcept {
smbc_getFunctionClosedir(ctx)(ctx, dir);
}
const struct smbc_dirent *ReadDirectory(SMBCFILE *dir) noexcept {
return smbc_getFunctionReaddir(ctx)(ctx, dir);
}
};
#endif