本文整理汇总了C++中CAfpConnection::GetVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ CAfpConnection::GetVolume方法的具体用法?C++ CAfpConnection::GetVolume怎么用?C++ CAfpConnection::GetVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAfpConnection
的用法示例。
在下文中一共展示了CAfpConnection::GetVolume方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Stat
// TODO - maybe check returncode!
int CAFPFile::Stat(const CURL& url, struct __stat64* buffer)
{
CSingleLock lock(gAfpConnection);
if (gAfpConnection.Connect(url) != CAfpConnection::AfpOk || !gAfpConnection.GetVolume())
return -1;
std::string strPath = gAfpConnection.GetPath(url);
struct stat tmpBuffer = {0};
int iResult = gAfpConnection.GetImpl()->afp_wrap_getattr(gAfpConnection.GetVolume(), strPath.c_str(), &tmpBuffer);
if (buffer)
{
memset(buffer, 0, sizeof(struct __stat64));
buffer->st_dev = tmpBuffer.st_dev;
buffer->st_ino = tmpBuffer.st_ino;
buffer->st_mode = tmpBuffer.st_mode;
buffer->st_nlink = tmpBuffer.st_nlink;
buffer->st_uid = tmpBuffer.st_uid;
buffer->st_gid = tmpBuffer.st_gid;
buffer->st_rdev = tmpBuffer.st_rdev;
buffer->st_size = tmpBuffer.st_size;
buffer->st_atime = tmpBuffer.st_atime;
buffer->st_mtime = tmpBuffer.st_mtime;
buffer->st_ctime = tmpBuffer.st_ctime;
}
return iResult;
}
示例2: Write
int CFileAFP::Write(const void* lpBuf, int64_t uiBufSize)
{
CSingleLock lock(gAfpConnection);
if (m_pFp == NULL || !gAfpConnection.GetVolume())
return -1;
int numberOfBytesWritten = 0;
uid_t uid;
gid_t gid;
// FIXME need a better way to get server's uid/gid
uid = getuid();
gid = getgid();
#ifdef USE_CVS_AFPFS
char *name = m_pFp->basename;
#else
char *name = m_pFp->name;
if (strlen(name) == 0)
name = m_pFp->basename;
#endif
numberOfBytesWritten = gAfpConnection.GetImpl()->afp_wrap_write(gAfpConnection.GetVolume(),
name, (const char *)lpBuf, (size_t)uiBufSize, m_fileOffset, m_pFp, uid, gid);
return numberOfBytesWritten;
}
示例3: Read
unsigned int CFileAFP::Read(void *lpBuf, int64_t uiBufSize)
{
CSingleLock lock(gAfpConnection);
if (m_pFp == NULL || !gAfpConnection.GetVolume())
return 0;
if (uiBufSize > AFP_MAX_READ_SIZE)
uiBufSize = AFP_MAX_READ_SIZE;
#ifdef USE_CVS_AFPFS
char *name = m_pFp->basename;
#else
char *name = m_pFp->name;
if (strlen(name) == 0)
name = m_pFp->basename;
#endif
int eof = 0;
int bytesRead = gAfpConnection.GetImpl()->afp_wrap_read(gAfpConnection.GetVolume(),
name, (char *)lpBuf,(size_t)uiBufSize, m_fileOffset, m_pFp, &eof);
if (bytesRead > 0)
m_fileOffset += bytesRead;
if (bytesRead < 0)
{
CLog::Log(LOGERROR, "%s - Error( %d, %d, %s )", __FUNCTION__, bytesRead, errno, strerror(errno));
return 0;
}
return (unsigned int)bytesRead;
}
示例4: Delete
bool CAFPFile::Delete(const CURL& url)
{
CSingleLock lock(gAfpConnection);
if (gAfpConnection.Connect(url) != CAfpConnection::AfpOk || !gAfpConnection.GetVolume())
return false;
std::string strPath = gAfpConnection.GetPath(url);
int result = gAfpConnection.GetImpl()->afp_wrap_unlink(gAfpConnection.GetVolume(), strPath.c_str());
if (result != 0)
CLog::Log(LOGERROR, "%s - Error( %s )", __FUNCTION__, strerror(errno));
return (result == 0);
}
示例5: Open
bool CAFPFile::Open(const CURL& url)
{
Close();
// we can't open files like afp://file.f or afp://server/file.f
// if a file matches the if below return false, it can't exist on a afp share.
if (!IsValidFile(url.GetFileName()))
{
CLog::Log(LOGNOTICE, "FileAfp: Bad URL : '%s'", url.GetFileName().c_str());
return false;
}
CSingleLock lock(gAfpConnection);
if (gAfpConnection.Connect(url) != CAfpConnection::AfpOk || !gAfpConnection.GetVolume())
return false;
m_pAfpVol = gAfpConnection.GetVolume();
std::string strPath = gAfpConnection.GetPath(url);
if (gAfpConnection.GetImpl()->afp_wrap_open(m_pAfpVol, strPath.c_str(), O_RDONLY, &m_pFp))
{
if (gAfpConnection.GetImpl()->afp_wrap_open(m_pAfpVol, CURL::Encode(strPath.c_str()).c_str(), O_RDONLY, &m_pFp))
{
// write error to logfile
CLog::Log(LOGINFO, "CAFPFile::Open: Unable to open file : '%s'\nunix_err:'%x' error : '%s'", strPath.c_str(), errno, strerror(errno));
return false;
}
}
CLog::Log(LOGDEBUG,"CAFPFile::Open - opened %s, fd=%d",url.GetFileName().c_str(), m_pFp ? m_pFp->fileid:-1);
m_url = url;
#ifdef TARGET_POSIX
struct __stat64 tmpBuffer;
#else
struct stat tmpBuffer;
#endif
if(Stat(&tmpBuffer))
{
m_url.Reset();
Close();
return false;
}
m_fileSize = tmpBuffer.st_size;
m_fileOffset = 0;
// We've successfully opened the file!
return true;
}
示例6: Rename
bool CAFPFile::Rename(const CURL& url, const CURL& urlnew)
{
CSingleLock lock(gAfpConnection);
if (gAfpConnection.Connect(url) != CAfpConnection::AfpOk || !gAfpConnection.GetVolume())
return false;
CStdString strFile = gAfpConnection.GetPath(url);
CStdString strFileNew = gAfpConnection.GetPath(urlnew);
int result = gAfpConnection.GetImpl()->afp_wrap_rename(gAfpConnection.GetVolume(), strFile.c_str(), strFileNew.c_str());
if (result != 0)
CLog::Log(LOGERROR, "%s - Error( %s )", __FUNCTION__, strerror(errno));
return (result == 0);
}
示例7: Close
void CFileAFP::Close()
{
CSingleLock lock(gAfpConnection);
if (m_pFp != NULL && gAfpConnection.GetVolume())
{
CLog::Log(LOGDEBUG, "CFileAFP::Close closing fd %d", m_pFp->fileid);
#ifdef USE_CVS_AFPFS
char *name = m_pFp->basename;
#else
char *name = m_pFp->name;
if (strlen(name) == 0)
name = m_pFp->basename;
#endif
gAfpConnection.GetImpl()->afp_wrap_close(gAfpConnection.GetVolume(), name, m_pFp);
delete m_pFp;
m_pFp = NULL;
}
}
示例8: OpenForWrite
bool CAFPFile::OpenForWrite(const CURL& url, bool bOverWrite)
{
int ret = 0;
m_fileSize = 0;
m_fileOffset = 0;
Close();
CSingleLock lock(gAfpConnection);
if (gAfpConnection.Connect(url) != CAfpConnection::AfpOk || !gAfpConnection.GetVolume())
return false;
// we can't open files like afp://file.f or afp://server/file.f
// if a file matches the if below return false, it can't exist on a afp share.
if (!IsValidFile(url.GetFileName()))
return false;
m_pAfpVol = gAfpConnection.GetVolume();
std::string strPath = gAfpConnection.GetPath(url);
if (bOverWrite)
{
CLog::Log(LOGWARNING, "FileAFP::OpenForWrite() called with overwriting enabled! - %s", strPath.c_str());
ret = gAfpConnection.GetImpl()->afp_wrap_creat(m_pAfpVol, strPath.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
}
ret = gAfpConnection.GetImpl()->afp_wrap_open(m_pAfpVol, strPath.c_str(), O_RDWR, &m_pFp);
if (ret || m_pFp == NULL)
{
// write error to logfile
CLog::Log(LOGERROR, "CAFPFile::Open: Unable to open file : '%s'\nunix_err:'%x' error : '%s'", strPath.c_str(), errno, strerror(errno));
return false;
}
// We've successfully opened the file!
return true;
}