Commit 03bcfc8e authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

В класс CFile добавлены функции Tell и Size. Добавлены функции превращающие...

В класс CFile добавлены функции Tell и Size. Добавлены функции превращающие стандартную строку std::wstring в верхний индекс и в нижний индекс.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63066 954022d7-b5bf-4e40-9824-e11837661b57
parent 608664db
......@@ -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_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment