本文整理汇总了C++中CAfpConnection类的典型用法代码示例。如果您正苦于以下问题:C++ CAfpConnection类的具体用法?C++ CAfpConnection怎么用?C++ CAfpConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAfpConnection类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
// 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: lock
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);
}
示例3: 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;
}
示例4: 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;
}
示例5:
CAFPFile::CAFPFile()
: m_fileSize(0)
, m_fileOffset(0)
, m_pFp(NULL)
, m_pAfpVol(NULL)
{
gAfpConnection.AddActiveConnection();
}
示例6: 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;
}
}
示例7: Close
CAFPFile::~CAFPFile()
{
gAfpConnection.AddIdleConnection();
Close();
}