mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
В класс CFile добавлены функции Tell и Size. Добавлены функции превращающие стандартную строку std::wstring в верхний индекс и в нижний индекс.
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63066 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
committed by
Alexander Trofimov
parent
608664db59
commit
03bcfc8eb3
@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <time.h>
|
||||
#include "Array.h"
|
||||
#include "errno.h"
|
||||
#include "Base64.h"
|
||||
@ -569,7 +570,6 @@ namespace NSFile
|
||||
{
|
||||
return m_pFile;
|
||||
}
|
||||
|
||||
inline long GetFileSize()
|
||||
{
|
||||
return m_lFileSize;
|
||||
@ -642,12 +642,12 @@ namespace NSFile
|
||||
m_lFilePosition = 0;
|
||||
return true;
|
||||
}
|
||||
bool SeekFile(int lFilePosition)
|
||||
bool SeekFile(int lFilePosition, int nSeekMode = 0)
|
||||
{
|
||||
if (!m_pFile)
|
||||
return false;
|
||||
|
||||
m_lFilePosition = fseek(m_pFile, lFilePosition, 0);
|
||||
m_lFilePosition = fseek(m_pFile, lFilePosition, nSeekMode);
|
||||
return true;
|
||||
}
|
||||
bool ReadFile(BYTE* pData, DWORD nBytesToRead, DWORD& dwSizeRead)
|
||||
@ -666,6 +666,25 @@ namespace NSFile
|
||||
size_t nCountWrite = fwrite((void*)pData, 1, nBytesCount, m_pFile);
|
||||
return true;
|
||||
}
|
||||
long TellFile()
|
||||
{
|
||||
if (!m_pFile)
|
||||
return 0;
|
||||
|
||||
return ftell(m_pFile);
|
||||
}
|
||||
long SizeFile()
|
||||
{
|
||||
if (!m_pFile)
|
||||
return 0;
|
||||
|
||||
long lPos = TellFile();
|
||||
fseek(m_pFile, 0, SEEK_END);
|
||||
m_lFileSize = ftell(m_pFile);
|
||||
fseek(m_pFile, lPos, SEEK_SET);
|
||||
|
||||
return m_lFileSize;
|
||||
}
|
||||
void WriteStringUTF8(const std::wstring& strXml, bool bIsBOM = false)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "CPEncodings/CodePage.h"
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
namespace NSString
|
||||
{
|
||||
@ -234,6 +235,24 @@ namespace NSString
|
||||
|
||||
return arrElements;
|
||||
}
|
||||
static inline void ToLower(std::wstring& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towlower);
|
||||
}
|
||||
static inline void ToUpper(std::wstring& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towupper);
|
||||
}
|
||||
static inline void Replace(std::wstring& wsString, const std::wstring& wsFrom, const std::wstring& wsTo)
|
||||
{
|
||||
int nFromLen = wsFrom.length();
|
||||
int nToLen = wsTo.length();
|
||||
int nPos = -nToLen;
|
||||
while (std::wstring::npos != (nPos = wsString.find(wsFrom, nPos + nToLen)))
|
||||
{
|
||||
wsString.replace(nPos, nFromLen, wsTo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _BUILD_STRING_CROSSPLATFORM_H_
|
||||
|
||||
Reference in New Issue
Block a user