HRESULT __stdcall CArchiveOpenVolumeCallback::GetStream(const wchar_t *name, IInStream **inStream)
{
//	if ( m_uOpenedVolumes == m_pArchive->GetNumberOfVolumes() )
//		return S_FALSE;

	string strFullName;
	string strFileName;

#ifdef UNICODE
	strFileName = name;
#else
	strFileName.SetData(name, CP_OEMCP);
#endif

	strFullName = m_pArchive->GetFileName();
	CutTo(strFullName, _T('\\'), false);
	strFullName += strFileName;

	//bool bResult = false;

	//CInFile* file = nullptr;

	CInFile* file = new CInFile(strFullName);

	bool bResult = file->Open();

/*	while ( true )
	{
		file = new CInFile(strFullName);

		if ( file->Open() )
		{
			m_uOpenedVolumes++;

			bResult = true;
			break;
		}
		else
		{
			TCHAR cBuffer[512];
			
			if ( m_pArchive->OnNeedVolume(strFullName, 512, (TCHAR*)&cBuffer) )
			{
				strFullName = (const TCHAR*)&cBuffer;
				delete file;
			}
			else
			{
				bResult = false;
				break;
			}
		}
	} */

	*inStream = file;
	m_pVolumeFile = file;

	return bResult?S_OK:S_FALSE;
}
Example #2
0
void LoadEarlyInit(COutStream& out)
{
    CInFile file;
    if (!file.Open(L"earlyinit.txt"))
        return; // may not exist

    char line[4096];
    while (file.ReadLine<char>(line, NELEMS(line), NULL)) {
        commands::ProcessCommand(line, out);
        *g_PrintStream << line << endl;
    }
}
Example #3
0
bool GetReparseData(CFSTR path, CByteBuffer &reparseData, BY_HANDLE_FILE_INFORMATION *fileInfo)
{
  reparseData.Free();
  CInFile file;
  if (!file.OpenReparse(path))
    return false;

  if (fileInfo)
    file.GetFileInformation(fileInfo);

  const unsigned kBufSize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
  CByteArr buf(kBufSize);
  DWORD returnedSize;
  if (!file.DeviceIoControlOut(my_FSCTL_GET_REPARSE_POINT, buf, kBufSize, &returnedSize))
    return false;
  reparseData.CopyFrom(buf, returnedSize);
  return true;
}
Example #4
0
HRESULT __stdcall CArchiveOpenVolumeCallback::GetStream (const wchar_t *name, IInStream **inStream)
{
	char szFullName[MAX_PATH];
	char szFileName[MAX_PATH];

	WideCharToMultiByte(CP_OEMCP, 0, name, -1, szFileName, MAX_PATH, NULL, NULL);

	strcpy (szFullName, m_pArchive->m_lpFileName.c_str());
	strcat (szFullName, szFileName);

	CInFile *file = new CInFile (szFullName);

	bool bResult = file->Open();

	*inStream = file;
	m_pVolumeFile = file;

	return bResult?S_OK:S_FALSE;
}
Example #5
0
	void LoadAdminList(const std::wstring adminPath, COutStream* out)
	{
		CInFile file;
		if (!file.Open(adminPath))
			return; // may not exist

		char line[4096];
		int n = 1;
		while (file.ReadLine<char>(line, NELEMS(line), NULL)) {
			std::vector<std::string> tokens = Tokenize<std::string>(line,",");
			if (tokens.size() == 3) {
				int level = atoi(tokens[2].c_str());
				result_t result = add(tokens[1], tokens[0], level);
				if (result == E_LEVEL_NOT_EXIST && out != NULL) {
					*out << adminPath << L" : invalid access level (line "
						<< n << L")" << endl; 
				}
			} else if (out) {
				*out << adminPath << L" : line " << n << 
					L" is incorrectly formatted." << endl;
			}
			n++;
		}
	}