Example #1
0
//BonDriverをロードしてチャンネル情報などを取得(ファイル名で指定)
//戻り値:
// エラーコード
//引数:
// bonDriverFile	[IN]EnumBonDriverで取得されたBonDriverのファイル名
DWORD CBonCtrl::OpenBonDriver(
	LPCWSTR bonDriverFile,
	int openWait
)
{
	if( Lock(L"OpenBonDriver-2") == FALSE ) return ERR_FALSE;
	_CloseBonDriver();
	DWORD ret = this->bonUtil.OpenBonDriver(bonDriverFile, openWait);
	wstring bonFile = this->bonUtil.GetOpenBonDriverFileName();
	if( ret == NO_ERR ){
		ret = _OpenBonDriver();
		this->tsOut.ResetChChange();

		this->tsOut.SetBonDriver(bonFile);
	}
	if( bonFile.empty() == false ){
		wstring settingPath;
		GetSettingPath(settingPath);
		wstring bonFileTitle;
		GetFileTitle(bonFile, bonFileTitle);
		wstring tunerName = this->bonUtil.GetTunerName();
		CheckFileName(tunerName);
		this->chUtil.LoadChSet( settingPath + L"\\" + bonFileTitle + L"(" + tunerName + L").ChSet4.txt", settingPath + L"\\ChSet5.txt" );
	}

	UnLock();
	return ret;
}
Example #2
0
			fclose(m_fp);

		}

		else

		{

			return false;

		}

	}

	

	//m_fp = _fsopen(m_szLogFile, "rb+", _SH_DENYWR);

	if (m_nOpenMode == LOG_OPENFORWRITE)

		m_fp = sh_fopen(m_szLogFile,"rb+",SH_DENYNO);

	else

		m_fp = sh_fopen(m_szLogFile,"rb",SH_DENYNO);



	if(m_fp != NULL)

	{

		ReadFileHead();

		if(m_stHead.stInfo.dwTotalLen < m_stHead.stInfo.dwValidLen

			|| m_stHead.stInfo.dwHeadLen != sizeof(m_stHead)

			|| m_stHead.stInfo.wVer != 100)

		{

			m_nOpenMode = LOG_OPENNODEFINE; //  防止误写别人的文件

			CloseLogFile();

			return false;

		}

		if(strcmp(m_stHead.stInfo.szCompany, COMPANYNAME)

			|| strcmp(m_stHead.stInfo.szProduct, PRODUCTNAME))

		{

			m_nOpenMode = LOG_OPENNODEFINE; //  防止误写别人的文件

			CloseLogFile();
Example #3
0
VOID DispatchCleanup(HANDLE Handle, PEVENT_CONTEXT EventContext,
                     PDOKAN_INSTANCE DokanInstance) {
  PEVENT_INFORMATION eventInfo;
  DOKAN_FILE_INFO fileInfo;
  PDOKAN_OPEN_INFO openInfo;
  ULONG sizeOfEventInfo = sizeof(EVENT_INFORMATION);

  CheckFileName(EventContext->Operation.Cleanup.FileName);

  eventInfo = DispatchCommon(EventContext, sizeOfEventInfo, DokanInstance,
                             &fileInfo, &openInfo);

  eventInfo->Status = STATUS_SUCCESS; // return success at any case

  DbgPrint("###Cleanup %04d\n", openInfo != NULL ? openInfo->EventId : -1);

  if (DokanInstance->DokanOperations->Cleanup) {
    // ignore return value
    DokanInstance->DokanOperations->Cleanup(
        EventContext->Operation.Cleanup.FileName, &fileInfo);
  }

  if (openInfo != NULL)
    openInfo->UserContext = fileInfo.Context;

  SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);

  free(eventInfo);
}
bool CScreenshotSettingsPagePage::Apply()
{
	CString fileName = GuiTools::GetWindowText(GetDlgItem(IDC_SCREENSHOTFILENAMEEDIT));
	if(!CheckFileName(fileName))
	{
		MessageBox(TR("Имя файла содержит запрещенные символы!"));
		::SetFocus(GetDlgItem(IDC_SCREENSHOTFILENAMEEDIT));
		return false;
	}
	Settings.ScreenshotSettings.FilenameTemplate = fileName;
	
	Settings.ScreenshotSettings.Format = SendDlgItemMessage(IDC_FORMATLIST,CB_GETCURSEL,0,0);
	Settings.ScreenshotSettings.Quality = GetDlgItemInt(IDC_QUALITYEDIT);
	Settings.ScreenshotSettings.Delay = GetDlgItemInt(IDC_DELAYEDIT);
	Settings.ScreenshotSettings.ShowForeground = SendDlgItemMessage(IDC_FOREGROUNDWHENSHOOTING, BM_GETCHECK) == BST_CHECKED;

	Settings.ScreenshotSettings.Folder = GuiTools::GetWindowText(GetDlgItem(IDC_SCREENSHOTFOLDEREDIT));
	Settings.ScreenshotSettings.Format = SendDlgItemMessage(IDC_FORMATLIST,CB_GETCURSEL,0,0);
	Settings.ScreenshotSettings.Quality = GetDlgItemInt(IDC_QUALITYEDIT);
	Settings.ScreenshotSettings.Delay = GetDlgItemInt(IDC_DELAYEDIT);
	Settings.ScreenshotSettings.ShowForeground = SendDlgItemMessage(IDC_FOREGROUNDWHENSHOOTING, BM_GETCHECK) == BST_CHECKED;
	Settings.ScreenshotSettings.CopyToClipboard =  SendDlgItemMessage(IDC_ALWAYSCOPYTOCLIPBOARD, BM_GETCHECK) == BST_CHECKED;
	
	Settings.ScreenshotSettings.WindowHidingDelay = GetDlgItemInt(IDC_WINDOWHIDINGDELAY);

	Settings.ScreenshotSettings.RemoveCorners = SendDlgItemMessage(IDC_REMOVECORNERS, BM_GETCHECK)!=0;
	Settings.ScreenshotSettings.AddShadow = SendDlgItemMessage(IDC_ADDSHADOW, BM_GETCHECK)!=0;
	Settings.ScreenshotSettings.RemoveBackground = SendDlgItemMessage(IDC_REMOVEBACKGROUND, BM_GETCHECK)!=0;
	Settings.ScreenshotSettings.UseOldRegionScreenshotMethod = GuiTools::GetCheck(m_hWnd, IDC_USEOLDREGIONSCREENSHOTMETHOD );


	 Settings.TrayIconSettings.ShortenLinks = GuiTools::GetCheck(m_hWnd, IDC_SHORTENURLFROMTRAYCHECKBOX);

	return true;
}
// Check single file. If the is a valid CCD frame, creates a CFrameInfo 
// instance and prepends it the the list given as the last parameter.
// The new list is returned as return value.
bool CNewFilesChecker::CheckNewFile(const gchar *filepath, bool *try_again)
{
	bool retval = true;
	CFrameInfo info;

	gchar *basename = g_path_get_basename(filepath);
	if (!m_Prefix || CheckFileName(basename, m_Prefix)) {
		if (!g_Project->FileInProject(filepath)) {
			GError *error = NULL;
			if (!info.Init(filepath, &error)) {
				if (error) {
					*try_again = (error->code==CMPACK_ERR_CANT_OPEN_SRC);
					g_error_free(error);
				}
			} else {
				if ((!m_Filter || StrCaseCmp0(m_Filter, info.Filter())==0) &&
					(!m_Object || StrCaseCmp0(m_Object, info.Object())==0)) {
						retval = m_CBProc(info, m_CBData, try_again);
				}
			}
		}
	}
	g_free(basename);
	return retval;
}
Example #6
0
BOOL WINAPI _GetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName)
{
	if (CheckFileName(lpFileName, _T("RagAddress.ini")) == false)
	{
		typedef (WINAPI *lpGetPPStr)(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, DWORD, LPCTSTR);
		return reinterpret_cast<lpGetPPStr>(lpfnGetPPStr)(lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, lpFileName);
	}

	LPTSTR lpNewKeyName = new TCHAR[16];

	if (lstrcmpi(lpKeyName, _T("Exp")) == 0)
		lstrcpy(lpNewKeyName, _T("BaseExp"));
	else if (lstrcmpi(lpKeyName, _T("MaxExp")) == 0)
		lstrcpy(lpNewKeyName, _T("BaseExpNext"));
	else if (lstrcmpi(lpKeyName, _T("Job")) == 0)
		lstrcpy(lpNewKeyName, _T("JobExp"));
	else if (lstrcmpi(lpKeyName, _T("MaxJob")) == 0)
		lstrcpy(lpNewKeyName, _T("JobExpNext"));
	else if (lstrcmpi(lpKeyName, _T("MaxWeight")) == 0)
		lstrcpy(lpNewKeyName, _T("WeightMax"));
	else if (lstrcmpi(lpKeyName, _T("Name")) == 0)
		lstrcpy(lpNewKeyName, _T("CharName"));
	else
		lstrcpy(lpNewKeyName, lpKeyName);

	typedef (WINAPI *lpGetPPInt)(LPCTSTR, LPCTSTR, INT, LPCTSTR);
    wsprintf(lpReturnedString, _T("%08X"), reinterpret_cast<lpGetPPInt>(lpfnGetPPInt)(_T("RagAddress"), lpNewKeyName, 0, _T("./RoAddr.ini")));

	delete [] lpNewKeyName;
	return TRUE;
}
Example #7
0
VOID DispatchWrite(HANDLE Handle, PEVENT_CONTEXT EventContext,
                   PDOKAN_INSTANCE DokanInstance) {
  PEVENT_INFORMATION eventInfo;
  PDOKAN_OPEN_INFO openInfo;
  ULONG writtenLength = 0;
  NTSTATUS status;
  DOKAN_FILE_INFO fileInfo;
  BOOL bufferAllocated = FALSE;
  ULONG sizeOfEventInfo = sizeof(EVENT_INFORMATION);

  eventInfo = DispatchCommon(EventContext, sizeOfEventInfo, DokanInstance,
                             &fileInfo, &openInfo);

  // Since driver requested bigger memory,
  // allocate enough memory and send it to driver
  if (EventContext->Operation.Write.RequestLength > 0) {
    ULONG contextLength = EventContext->Operation.Write.RequestLength;
    PEVENT_CONTEXT contextBuf = (PEVENT_CONTEXT)malloc(contextLength);
    if (contextBuf == NULL) {
      free(eventInfo);
      return;
    }
    SendWriteRequest(Handle, eventInfo, sizeOfEventInfo, contextBuf,
                     contextLength);
    EventContext = contextBuf;
    bufferAllocated = TRUE;
  }

  CheckFileName(EventContext->Operation.Write.FileName);

  DbgPrint("###WriteFile %04d\n", openInfo != NULL ? openInfo->EventId : -1);

  if (DokanInstance->DokanOperations->WriteFile) {
    status = DokanInstance->DokanOperations->WriteFile(
        EventContext->Operation.Write.FileName,
        (PCHAR)EventContext + EventContext->Operation.Write.BufferOffset,
        EventContext->Operation.Write.BufferLength, &writtenLength,
        EventContext->Operation.Write.ByteOffset.QuadPart, &fileInfo);
  } else {
    status = STATUS_NOT_IMPLEMENTED;
  }

  if (openInfo != NULL)
    openInfo->UserContext = fileInfo.Context;
  eventInfo->Status = status;
  eventInfo->BufferLength = 0;

  if (status == STATUS_SUCCESS) {
    eventInfo->BufferLength = writtenLength;
    eventInfo->Operation.Write.CurrentByteOffset.QuadPart =
        EventContext->Operation.Write.ByteOffset.QuadPart + writtenLength;
  }

  SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);
  free(eventInfo);

  if (bufferAllocated)
    free(EventContext);
}
Example #8
0
UINT WINAPI _GetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName)
{
	typedef (WINAPI *lpGetPPInt)(LPCTSTR, LPCTSTR, INT, LPCTSTR);

	if (CheckFileName(lpFileName, _T("RagAddress.ini")))
		return reinterpret_cast<lpGetPPInt>(lpfnGetPPInt)(lpAppName, lpKeyName, nDefault, _T("./RoAddr.ini"));

	return reinterpret_cast<lpGetPPInt>(lpfnGetPPInt)(lpAppName, lpKeyName, nDefault, lpFileName);
}
Example #9
0
VOID
DispatchRead(
	HANDLE				Handle,
	PEVENT_CONTEXT		EventContext,
	PDOKAN_INSTANCE		DokanInstance)
{
	PEVENT_INFORMATION		eventInfo;
	PDOKAN_OPEN_INFO		openInfo;
	ULONG					readLength = 0;
	int						status;
	DOKAN_FILE_INFO			fileInfo;
	ULONG					sizeOfEventInfo;
	
	sizeOfEventInfo = sizeof(EVENT_INFORMATION) - 8 + EventContext->Operation.Read.BufferLength;

	CheckFileName(EventContext->Operation.Read.FileName);

	eventInfo = DispatchCommon(
		EventContext, sizeOfEventInfo, DokanInstance, &fileInfo, &openInfo);

	DbgPrint("###Read %04d\n", openInfo != NULL ? openInfo->EventId : -1);

	if (DokanInstance->DokanOperations->ReadFile) {
		status = DokanInstance->DokanOperations->ReadFile(
			EventContext->Operation.Read.FileName,
				eventInfo->Buffer,
				EventContext->Operation.Read.BufferLength,
				&readLength,
				EventContext->Operation.Read.ByteOffset.QuadPart,
				&fileInfo);
	} else {
		status = -1;
	}

	if (openInfo != NULL)
		openInfo->UserContext = fileInfo.Context;
	eventInfo->BufferLength = 0;

	if (status < 0) {
		eventInfo->Status = STATUS_INVALID_PARAMETER;
	} else if(readLength == 0) {
		eventInfo->Status = STATUS_END_OF_FILE;
	} else {
		eventInfo->Status = STATUS_SUCCESS;
		eventInfo->BufferLength = readLength;
		eventInfo->Operation.Read.CurrentByteOffset.QuadPart =
			EventContext->Operation.Read.ByteOffset.QuadPart + readLength;
	}

	SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);
	free(eventInfo);
	return;
}
Example #10
0
void JLogFile::WriteLogAction()
{
	m_cs.Enter();
	vector<wstring> logVec;
	for ( list<LogData>::iterator it = m_logList.begin(); it != m_logList.end(); ++it ){
		logVec.push_back(JLogUtils::LogData2String(*it));
	}
	m_logList.clear();
	m_cs.Leave();
	CheckFileName();
	m_cs.Enter();
    for(size_t i = 0; i < logVec.size(); i++)
	    JFileUtils::AppendStringFile(m_currentFileName, logVec[i]);
	m_cs.Leave();
}
Example #11
0
void JLogFile::WriteLog(wstring logText)
{		
	LogData data;
	data.dt = JDateTime::Now();
	data.text = logText;
	if( m_LogCathe ){
		m_cs.Enter();
		m_logList.push_back(data);
		m_cs.Leave();
	}else{
		CheckFileName();
		m_cs.Enter();
		JFileUtils::AppendStringFile(m_currentFileName, JLogUtils::LogData2String(data));
		m_cs.Leave();
	}	
}
void ViewNewMapDialog::PButtonOkClicked()
{
    if(QDir(LineEditFileDirectory.text()).exists())
    {
        if(CheckFileName(LineEditFileName.text()))
        {
            GLOBAL_VARS::MapDefaultDirectory = LineEditFileDirectory.text();
            const QString fileNamePath = QDir::toNativeSeparators(GLOBAL_VARS::MapDefaultDirectory + '/' + LineEditFileName.text() + GLOBAL_CONSTS::MapExtensionWithDot);
            File = new QFile(fileNamePath);
            QIODevice::OpenMode openModeFlag = QIODevice::ReadWrite;
            if(File->exists())
            {
                if(QMessageBox::Yes == QMessageBox::question(this,
                                                             tr("Are you sure ...?"),
                                                             tr("Do you want to overwrite the existing '%1' file?").arg(fileNamePath)))
                {
                    openModeFlag |= QIODevice::Truncate;
                }
                else
                {
                    return;
                }

            }
            if(File->open(openModeFlag))
            {
                accept();
            }
            else
            {
                QMessageBox::warning(this,
                                     tr("Worning ..."),
                                     tr("The file '%1' can not be created. Probably no permission or enougth space.").arg(fileNamePath));
            }
        }
    }
    else
    {
        QMessageBox::warning(this,
                             tr("Worning ..."),
                             tr("The directory '%1' is not exist.").arg(LineEditFileDirectory.text()));
    }
}
Example #13
0
VOID DispatchQuerySecurity(HANDLE Handle, PEVENT_CONTEXT EventContext,
                           PDOKAN_INSTANCE DokanInstance) {
  PEVENT_INFORMATION eventInfo;
  DOKAN_FILE_INFO fileInfo;
  PDOKAN_OPEN_INFO openInfo;
  ULONG eventInfoLength;
  NTSTATUS status = STATUS_NOT_IMPLEMENTED;
  ULONG lengthNeeded = 0;

  eventInfoLength = sizeof(EVENT_INFORMATION) - 8 +
                    EventContext->Operation.Security.BufferLength;
  CheckFileName(EventContext->Operation.Security.FileName);

  eventInfo = DispatchCommon(EventContext, eventInfoLength, DokanInstance,
                             &fileInfo, &openInfo);

  if (DokanInstance->DokanOperations->GetFileSecurity) {
    status = DokanInstance->DokanOperations->GetFileSecurity(
        EventContext->Operation.Security.FileName,
        &EventContext->Operation.Security.SecurityInformation,
        &eventInfo->Buffer, EventContext->Operation.Security.BufferLength,
        &lengthNeeded, &fileInfo);
  }

  eventInfo->Status = status;

  if (status != STATUS_SUCCESS && status != STATUS_BUFFER_OVERFLOW) {
    eventInfo->BufferLength = 0;
  } else {
    eventInfo->BufferLength = lengthNeeded;

    if (EventContext->Operation.Security.BufferLength < lengthNeeded) {
      // Filesystem Application should return STATUS_BUFFER_OVERFLOW in this
      // case.
      eventInfo->Status = STATUS_BUFFER_OVERFLOW;
    }
  }

  SendEventInformation(Handle, eventInfo, eventInfoLength, DokanInstance);
  free(eventInfo);
}
Example #14
0
VOID DispatchFlush(HANDLE Handle, PEVENT_CONTEXT EventContext,
                   PDOKAN_INSTANCE DokanInstance) {
  DOKAN_FILE_INFO fileInfo;
  PEVENT_INFORMATION eventInfo;
  ULONG sizeOfEventInfo = sizeof(EVENT_INFORMATION);
  PDOKAN_OPEN_INFO openInfo;
  NTSTATUS status;

  CheckFileName(EventContext->Operation.Flush.FileName);

  eventInfo = DispatchCommon(EventContext, sizeOfEventInfo, DokanInstance,
                             &fileInfo, &openInfo);

  DbgPrint("###Flush %04d\n", openInfo != NULL ? openInfo->EventId : -1);

  if (DokanInstance->DokanOperations->FlushFileBuffers) {

    status = DokanInstance->DokanOperations->FlushFileBuffers(
        EventContext->Operation.Flush.FileName, &fileInfo);

  } else {
    status = STATUS_NOT_IMPLEMENTED;
  }

  if (status == STATUS_NOT_IMPLEMENTED) {
    eventInfo->Status = STATUS_SUCCESS;
  } else {
    eventInfo->Status =
        status != STATUS_SUCCESS ? STATUS_NOT_SUPPORTED : STATUS_SUCCESS;
  }

  if (openInfo != NULL)
    openInfo->UserContext = fileInfo.Context;

  SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);

  free(eventInfo);
  return;
}
Example #15
0
VOID
DispatchClose(
	HANDLE				Handle,
	PEVENT_CONTEXT		EventContext,
	PDOKAN_INSTANCE		DokanInstance)
{
	PEVENT_INFORMATION		eventInfo;
	DOKAN_FILE_INFO			fileInfo;	
	PDOKAN_OPEN_INFO		openInfo;
	ULONG					sizeOfEventInfo = sizeof(EVENT_INFORMATION);

	CheckFileName(EventContext->Close.FileName);

	eventInfo = DispatchCommon(
		EventContext, sizeOfEventInfo, DokanInstance, &fileInfo, &openInfo);

	eventInfo->Status = STATUS_SUCCESS; // return success at any case

	DbgPrint("###Close %04d\n", openInfo != NULL ? openInfo->EventId : -1);

	if (DokanInstance->DokanOperations->CloseFile) {
		// ignore return value
		DokanInstance->DokanOperations->CloseFile(
			EventContext->Close.FileName, &fileInfo);
	}

	// do not send it to the driver
	//SendEventInformation(Handle, eventInfo, length);

	if (openInfo != NULL) {
		EnterCriticalSection(&DokanInstance->CriticalSection);
		openInfo->OpenCount--;
		LeaveCriticalSection(&DokanInstance->CriticalSection);
	}
	ReleaseDokanOpenInfo(eventInfo, DokanInstance);
	free(eventInfo);

	return;
}
Example #16
0
VOID
DispatchFlush(
	HANDLE				Handle,
	PEVENT_CONTEXT		EventContext,
	PDOKAN_INSTANCE		DokanInstance)
{
	DOKAN_FILE_INFO		fileInfo;
	PEVENT_INFORMATION	eventInfo;
	ULONG				sizeOfEventInfo = sizeof(EVENT_INFORMATION);
	PDOKAN_OPEN_INFO	openInfo;
	int status;

	CheckFileName(EventContext->Flush.FileName);

	eventInfo = DispatchCommon(EventContext, sizeOfEventInfo, DokanInstance, &fileInfo);
	openInfo = (PDOKAN_OPEN_INFO)EventContext->Context;

	DbgPrint("###Flush %04d\n", openInfo->EventId);

	eventInfo->Status = STATUS_SUCCESS;

	if (DokanInstance->DokanOperations->FlushFileBuffers) {

		status = DokanInstance->DokanOperations->FlushFileBuffers(
					EventContext->Flush.FileName,
					&fileInfo);

		eventInfo->Status = status < 0 ?
					STATUS_NOT_SUPPORTED : STATUS_SUCCESS;
	}

	openInfo->UserContext = fileInfo.Context;

	SendEventInformation(Handle, eventInfo, sizeOfEventInfo);

	free(eventInfo);
	return;
}
Example #17
0
VOID DispatchSetSecurity(HANDLE Handle, PEVENT_CONTEXT EventContext,
                         PDOKAN_INSTANCE DokanInstance) {
  PEVENT_INFORMATION eventInfo;
  DOKAN_FILE_INFO fileInfo;
  PDOKAN_OPEN_INFO openInfo;
  ULONG eventInfoLength;
  NTSTATUS status = STATUS_NOT_IMPLEMENTED;
  PSECURITY_DESCRIPTOR securityDescriptor;

  eventInfoLength = sizeof(EVENT_INFORMATION);
  CheckFileName(EventContext->Operation.SetSecurity.FileName);

  eventInfo = DispatchCommon(EventContext, eventInfoLength, DokanInstance,
                             &fileInfo, &openInfo);

  securityDescriptor =
      (PCHAR)EventContext + EventContext->Operation.SetSecurity.BufferOffset;

  if (DokanInstance->DokanOperations->SetFileSecurity) {
    status = DokanInstance->DokanOperations->SetFileSecurity(
        EventContext->Operation.SetSecurity.FileName,
        &EventContext->Operation.SetSecurity.SecurityInformation,
        securityDescriptor, EventContext->Operation.SetSecurity.BufferLength,
        &fileInfo);
  }

  if (status > 0) {
    eventInfo->Status = STATUS_INVALID_PARAMETER;
    eventInfo->BufferLength = 0;
  } else {
    eventInfo->Status = STATUS_SUCCESS;
    eventInfo->BufferLength = 0;
  }

  SendEventInformation(Handle, eventInfo, eventInfoLength, DokanInstance);
  free(eventInfo);
}
Example #18
0
int DetermineFileName(char *name)
{
  char newName[MAXFILENAME], suffix[MAXFILENAME];
  int  i;
  
  /* Without extension */
  if (ExistFile(name))
  {
    return 1;
  }
 
  for (i = 0; i < 3; i++)
  {
    if (i == 0)      /* Try TS-file extension */
      strcpy(suffix, FormatNameTS);
      
    else if (i == 1)  /* Try CB-file extension */
      strcpy(suffix, FormatNameCB);
      
    else             /* Try PA-file extension */
      strcpy(suffix, FormatNamePA);
    
    if (strlen(name) < MAXFILENAME-strlen(suffix)-1)
    {
      strcpy(newName, name);
      CheckFileName(newName, suffix);
      if (ExistFile(newName))
      {
        strcpy(name, newName);
        return 1;
      }
    }
  }

  /* No luck this time */
  return 0;
}  /* DetermineFileName() */
Example #19
0
	if(!strlen(m_szLogFile))

	{

		return false;

	}

	if(m_fp != NULL)

	{

		return false;

	}



 	if(access(m_szLogFile, 0)== -1 && m_nOpenMode == LOG_OPENFORWRITE)

	{

		m_fp = sh_fopen(m_szLogFile, "ab+",SH_DENYNO);

		if(m_fp != NULL)

		{

			fclose(m_fp);

			m_fp = sh_fopen(m_szLogFile, "rb+",SH_DENYNO);

			ResizeFile();

			SaveFileHead(true);
Example #20
0
void JLogFile::WriteLog(list<wstring> logList)
{	
	wstring logText;
	LogData data;
	vector<wstring> logVec;
	data.dt = JDateTime::Now();
	for ( list<wstring>::iterator it = logList.begin(); it != logList.end(); ++it ){
		data.text = *it;
		if( m_LogCathe ){
			m_cs.Enter();
			m_logList.push_back(data);
			m_cs.Leave();
		}else{
			logVec.push_back(JLogUtils::LogData2String(data));
		}
	}
	if( !m_LogCathe ){
		CheckFileName();
		m_cs.Enter();
        for(size_t i = 0; i < logVec.size(); i++)
		    JFileUtils::AppendStringFile(m_currentFileName, logVec[i]);
		m_cs.Leave();
	}	
}
Example #21
0
VOID DispatchDirectoryInformation(HANDLE Handle, PEVENT_CONTEXT EventContext,
                                  PDOKAN_INSTANCE DokanInstance) {
  PEVENT_INFORMATION eventInfo;
  DOKAN_FILE_INFO fileInfo;
  PDOKAN_OPEN_INFO openInfo;
  NTSTATUS status = STATUS_SUCCESS;
  ULONG fileInfoClass = EventContext->Operation.Directory.FileInformationClass;
  ULONG sizeOfEventInfo = sizeof(EVENT_INFORMATION) - 8 +
                          EventContext->Operation.Directory.BufferLength;

  BOOLEAN patternCheck = TRUE;

  CheckFileName(EventContext->Operation.Directory.DirectoryName);

  eventInfo = DispatchCommon(EventContext, sizeOfEventInfo, DokanInstance,
                             &fileInfo, &openInfo);

  // check whether this is handled FileInfoClass
  if (fileInfoClass != FileDirectoryInformation &&
      fileInfoClass != FileFullDirectoryInformation &&
      fileInfoClass != FileNamesInformation &&
      fileInfoClass != FileIdBothDirectoryInformation &&
      fileInfoClass != FileBothDirectoryInformation) {

    DbgPrint("not suported type %d\n", fileInfoClass);

    // send directory info to driver
    eventInfo->BufferLength = 0;
    eventInfo->Status = STATUS_NOT_IMPLEMENTED;
    SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);
    free(eventInfo);
    return;
  }

  // IMPORTANT!!
  // this buffer length is fixed in MatchFiles funciton
  eventInfo->BufferLength = EventContext->Operation.Directory.BufferLength;

  if (openInfo->DirListHead == NULL) {
    openInfo->DirListHead = malloc(sizeof(LIST_ENTRY));
    if (openInfo->DirListHead != NULL) {
      InitializeListHead(openInfo->DirListHead);
    } else {
      eventInfo->BufferLength = 0;
      eventInfo->Status = STATUS_NO_MEMORY;
      SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);
      free(eventInfo);
      return;
    }
  }

  if (EventContext->Operation.Directory.FileIndex == 0) {
    ClearFindData(openInfo->DirListHead);
  }

  if (IsListEmpty(openInfo->DirListHead)) {

    DbgPrint("###FindFiles %04d\n", openInfo->EventId);

    // if user defined FindFilesWithPattern
    if (DokanInstance->DokanOperations->FindFilesWithPattern) {
      LPCWSTR pattern = L"*";

      // if search pattern is specified
      if (EventContext->Operation.Directory.SearchPatternLength != 0) {
        pattern = (PWCHAR)(
            (SIZE_T)&EventContext->Operation.Directory.SearchPatternBase[0] +
            (SIZE_T)EventContext->Operation.Directory.SearchPatternOffset);
      }

      patternCheck = FALSE; // do not recheck pattern later in MatchFiles

      status = DokanInstance->DokanOperations->FindFilesWithPattern(
          EventContext->Operation.Directory.DirectoryName, pattern,
          DokanFillFileData, &fileInfo);

    } else {
      status = STATUS_NOT_IMPLEMENTED;
    }

    if (status == STATUS_NOT_IMPLEMENTED &&
        DokanInstance->DokanOperations->FindFiles) {

      patternCheck = TRUE; // do pattern check later in MachFiles

      // call FileSystem specifeid callback routine
      status = DokanInstance->DokanOperations->FindFiles(
          EventContext->Operation.Directory.DirectoryName, DokanFillFileData,
          &fileInfo);
    }
  }

  if (status != STATUS_SUCCESS) {

    if (EventContext->Operation.Directory.FileIndex == 0) {
      DbgPrint("  STATUS_NO_SUCH_FILE\n");
      eventInfo->Status = STATUS_NO_SUCH_FILE;
    } else {
      DbgPrint("  STATUS_NO_MORE_FILES\n");
      eventInfo->Status = STATUS_NO_MORE_FILES;
    }

    eventInfo->BufferLength = 0;
    eventInfo->Operation.Directory.Index =
        EventContext->Operation.Directory.FileIndex;
    // free all of list entries
    ClearFindData(openInfo->DirListHead);
  } else {
    LONG index;
    eventInfo->Status = STATUS_SUCCESS;

    AddMissingCurrentAndParentFolder(EventContext, openInfo->DirListHead,
                                     &fileInfo);

    DbgPrint("index from %d\n", EventContext->Operation.Directory.FileIndex);
    // extract entries that match search pattern from FindFiles result
    index = MatchFiles(EventContext, eventInfo, openInfo->DirListHead,
                       patternCheck, DokanInstance);

    // there is no matched file
    if (index < 0) {
      eventInfo->BufferLength = 0;
      eventInfo->Operation.Directory.Index =
          EventContext->Operation.Directory.FileIndex;
      if (index == -1) {
        if (EventContext->Operation.Directory.FileIndex == 0) {
          DbgPrint("  STATUS_NO_SUCH_FILE\n");
          eventInfo->Status = STATUS_NO_SUCH_FILE;
        } else {
          DbgPrint("  STATUS_NO_MORE_FILES\n");
          eventInfo->Status = STATUS_NO_MORE_FILES;
        }
      } else {
        DbgPrint("  STATUS_BUFFER_OVERFLOW\n");
        eventInfo->Status = STATUS_BUFFER_OVERFLOW;
      }
      ClearFindData(openInfo->DirListHead);
    } else {
      DbgPrint("index to %d\n", index);
      eventInfo->Operation.Directory.Index = index;
    }
  }

  // information for FileSystem
  openInfo->UserContext = fileInfo.Context;

  // send directory information to driver
  SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);
  free(eventInfo);
}
Example #22
0
VOID
DispatchQueryInformation(
	HANDLE				Handle,
	PEVENT_CONTEXT		EventContext,
	PDOKAN_INSTANCE		DokanInstance)
{
	PEVENT_INFORMATION			eventInfo;
	DOKAN_FILE_INFO				fileInfo;
	BY_HANDLE_FILE_INFORMATION	byHandleFileInfo;
	ULONG				remainingLength;
    ULONG				status = STATUS_INVALID_PARAMETER;
	int					result;
	PDOKAN_OPEN_INFO	openInfo;
	ULONG				sizeOfEventInfo;

	sizeOfEventInfo = sizeof(EVENT_INFORMATION) - 8 + EventContext->File.BufferLength;

	CheckFileName(EventContext->File.FileName);

	ZeroMemory(&byHandleFileInfo, sizeof(BY_HANDLE_FILE_INFORMATION));

	eventInfo = DispatchCommon(
		EventContext, sizeOfEventInfo, DokanInstance, &fileInfo, &openInfo);
	
	eventInfo->BufferLength = EventContext->File.BufferLength;

	DbgPrint("###GetFileInfo %04d\n", openInfo != NULL ? openInfo->EventId : -1);

	if (DokanInstance->DokanOperations->GetFileInformation) {
		result = DokanInstance->DokanOperations->GetFileInformation(
										EventContext->File.FileName,
										&byHandleFileInfo,
										&fileInfo);
	} else {
		result = -1;
	}

	remainingLength = eventInfo->BufferLength;

	if (result < 0) {
		eventInfo->Status = STATUS_INVALID_PARAMETER;
		eventInfo->BufferLength = 0;
	
	} else {

		switch(EventContext->File.FileInformationClass) {
		case FileBasicInformation:
			//DbgPrint("FileBasicInformation\n");
            status = DokanFillFileBasicInfo((PFILE_BASIC_INFORMATION)eventInfo->Buffer,
										&byHandleFileInfo, &remainingLength);
			break;

		case FileInternalInformation:
            status = DokanFillInternalInfo((PFILE_INTERNAL_INFORMATION)eventInfo->Buffer,
											&byHandleFileInfo, &remainingLength);
			break;

		case FileEaInformation:
			//DbgPrint("FileEaInformation or FileInternalInformation\n");
			//status = STATUS_NOT_IMPLEMENTED;
			status = STATUS_SUCCESS;
			remainingLength -= sizeof(FILE_EA_INFORMATION);
			break;

		case FileStandardInformation:
			//DbgPrint("FileStandardInformation\n");
            status = DokanFillFileStandardInfo((PFILE_STANDARD_INFORMATION)eventInfo->Buffer,
										&byHandleFileInfo, &remainingLength);
			break;

		case FileAllInformation:
			//DbgPrint("FileAllInformation\n");
            status = DokanFillFileAllInfo((PFILE_ALL_INFORMATION)eventInfo->Buffer,
										&byHandleFileInfo, &remainingLength, EventContext);
			break;

		case FileAlternateNameInformation:
			status = STATUS_NOT_IMPLEMENTED;
			break;

		case FileAttributeTagInformation:
            status = DokanFillFileAttributeTagInfo((PFILE_ATTRIBUTE_TAG_INFORMATION)eventInfo->Buffer,
										&byHandleFileInfo, &remainingLength);
			break;

		case FileCompressionInformation:
			//DbgPrint("FileAlternateNameInformation or...\n");
			status = STATUS_NOT_IMPLEMENTED;
			break;

		case FileNameInformation:
			// this case is not used because driver deal with
			//DbgPrint("FileNameInformation\n");
            status = DokanFillFileNameInfo((PFILE_NAME_INFORMATION)eventInfo->Buffer,
								&byHandleFileInfo, &remainingLength, EventContext);
			break;

		case FileNetworkOpenInformation:
			//DbgPrint("FileNetworkOpenInformation\n");
            status = DokanFillNetworkOpenInfo((PFILE_NETWORK_OPEN_INFORMATION)eventInfo->Buffer,
								&byHandleFileInfo, &remainingLength);
			break;

		case FilePositionInformation:
			// this case is not used because driver deal with
			//DbgPrint("FilePositionInformation\n");
            status = DokanFillFilePositionInfo((PFILE_POSITION_INFORMATION)eventInfo->Buffer,
								&byHandleFileInfo, &remainingLength);

			break;
		case FileStreamInformation:
			//DbgPrint("FileStreamInformation\n");
			status = STATUS_NOT_IMPLEMENTED;
			break;
        default:
			{
				DbgPrint("  unknown type:%d\n", EventContext->File.FileInformationClass);
			}
            break;
		}
	
		eventInfo->Status = status;
		eventInfo->BufferLength = EventContext->File.BufferLength - remainingLength;
	}

	// information for FileSystem
	openInfo->UserContext = fileInfo.Context;

	SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);
	free(eventInfo);
	return;

}
Example #23
0
UINT WINAPI CBonCtrl::ChScanThread(LPVOID param)
{
	CBonCtrl* sys = (CBonCtrl*)param;

	sys->chUtil.Clear();

	wstring settingPath;
	GetSettingPath(settingPath);
	wstring bonFileTitle;
	GetFileTitle(sys->bonUtil.GetOpenBonDriverFileName(), bonFileTitle);
	wstring tunerName = sys->bonUtil.GetTunerName();
	CheckFileName(tunerName);

	wstring chSet4 = settingPath + L"\\" + bonFileTitle + L"(" + tunerName + L").ChSet4.txt";
	wstring chSet5 = settingPath + L"\\ChSet5.txt";

	vector<CHK_CH_INFO> chkList;
	map<DWORD, BON_SPACE_INFO> spaceMap;
	if( sys->bonUtil.GetOriginalChList(&spaceMap) != NO_ERR ){
		sys->chSt_err = ST_COMPLETE;
		sys->chUtil.SaveChSet(chSet4, chSet5);
		return 0;
	}
	map<DWORD, BON_SPACE_INFO>::iterator itrSpace;
	for( itrSpace = spaceMap.begin(); itrSpace != spaceMap.end(); itrSpace++ ){
		sys->chSt_totalNum += (DWORD)itrSpace->second.chMap.size();
		map<DWORD, wstring>::iterator itrCh;
		for( itrCh = itrSpace->second.chMap.begin(); itrCh != itrSpace->second.chMap.end(); itrCh++ ){
			CHK_CH_INFO item;
			item.space = itrSpace->first;
			item.spaceName = itrSpace->second.spaceName;
			item.ch = itrCh->first;
			item.chName = itrCh->second;
			chkList.push_back(item);
		}
	}

	if( sys->chSt_totalNum == 0 ){
		sys->chSt_err = ST_COMPLETE;
		sys->chUtil.SaveChSet(chSet4, chSet5);
		return 0;
	}

	wstring folderPath;
	GetModuleFolderPath( folderPath );
	wstring iniPath = folderPath;
	iniPath += L"\\BonCtrl.ini";

	DWORD chChgTimeOut = GetPrivateProfileInt(L"CHSCAN", L"ChChgTimeOut", 9, iniPath.c_str());
	DWORD serviceChkTimeOut = GetPrivateProfileInt(L"CHSCAN", L"ServiceChkTimeOut", 8, iniPath.c_str());


	DWORD wait = 0;
	BOOL chkNext = TRUE;
	DWORD startTime = 0;
	DWORD chkWait = 0;
	DWORD chkCount = 0;
	BOOL firstChg = FALSE;

	while(1){
		if( ::WaitForSingleObject(sys->chScanStopEvent, wait) != WAIT_TIMEOUT ){
			//キャンセルされた
			sys->chSt_err = ST_CANCEL;
			break;
		}
		if( chkNext == TRUE ){
			sys->chSt_space = chkList[chkCount].space;
			sys->chSt_ch = chkList[chkCount].ch;
			sys->chSt_chName = chkList[chkCount].chName;
			sys->_SetCh(chkList[chkCount].space, chkList[chkCount].ch, TRUE);
			if( firstChg == FALSE ){
				firstChg = TRUE;
				sys->tsOut.ResetChChange();
			}
			startTime = GetTickCount();
			chkNext = FALSE;
			wait = 1000;
			chkWait = chChgTimeOut;
		}else{
			BOOL chChgErr = FALSE;
			if( sys->tsOut.IsChChanging(&chChgErr) == TRUE ){
				if( GetTickCount() - startTime > chkWait * 1000 ){
					//チャンネル切り替えに8秒以上かかってるので無信号と判断
					OutputDebugString(L"★AutoScan Ch Change timeout\r\n");
					chkNext = TRUE;
				}
			}else{
				if( GetTickCount() - startTime > (chkWait + serviceChkTimeOut) * 1000 || chChgErr == TRUE){
					//チャンネル切り替え成功したけどサービス一覧とれないので無信号と判断
					OutputDebugString(L"★AutoScan GetService timeout\r\n");
					chkNext = TRUE;
				}else{
					//サービス一覧の取得を行う
					DWORD serviceListSize;
					SERVICE_INFO* serviceList;
					if( sys->tsOut.GetServiceListActual(&serviceListSize, &serviceList) == NO_ERR ){
						if( serviceListSize > 0 ){
							//一覧の取得ができた
							for( DWORD i=0 ;i<serviceListSize; i++ ){
								if( serviceList[i].extInfo != NULL ){
									if( serviceList[i].extInfo->service_name != NULL ){
										if( wcslen(serviceList[i].extInfo->service_name) > 0 ){
											sys->chUtil.AddServiceInfo(chkList[chkCount].space, chkList[chkCount].ch, chkList[chkCount].chName, &(serviceList[i]));
										}
									}
								}
							}
							chkNext = TRUE;
						}
					}
				}
			}
			if( chkNext == TRUE ){
				//次のチャンネルへ
				chkCount++;
				sys->chSt_chkNum++;
				if( sys->chSt_totalNum <= chkCount ){
					//全部チェック終わったので終了
					sys->chSt_err = ST_COMPLETE;
					sys->chUtil.SaveChSet(chSet4, chSet5);
					break;
				}
			}
		}
	}

	sys->chUtil.LoadChSet(chSet4, chSet5);

	return 0;
}
Example #24
0
VOID
DispatchSetInformation(
 	HANDLE				Handle,
	PEVENT_CONTEXT		EventContext,
	PDOKAN_INSTANCE		DokanInstance)
{
	PEVENT_INFORMATION		eventInfo;
	PDOKAN_OPEN_INFO		openInfo;
	DOKAN_FILE_INFO			fileInfo;
	NTSTATUS				status = STATUS_NOT_IMPLEMENTED;
	ULONG					sizeOfEventInfo = sizeof(EVENT_INFORMATION);


	if (EventContext->Operation.SetFile.FileInformationClass == FileRenameInformation) {
		PDOKAN_RENAME_INFORMATION renameInfo =
			(PDOKAN_RENAME_INFORMATION)((PCHAR)EventContext + EventContext->Operation.SetFile.BufferOffset);
		sizeOfEventInfo += renameInfo->FileNameLength;
	}

	CheckFileName(EventContext->Operation.SetFile.FileName);

	eventInfo = DispatchCommon(
		EventContext, sizeOfEventInfo, DokanInstance, &fileInfo, &openInfo);
	
	DbgPrint("###SetFileInfo %04d  %d\n", openInfo != NULL ? openInfo->EventId : -1, EventContext->Operation.SetFile.FileInformationClass);

	switch (EventContext->Operation.SetFile.FileInformationClass) {
	case FileAllocationInformation:
		status = DokanSetAllocationInformation(
				EventContext, &fileInfo, DokanInstance->DokanOperations);
		break;
	
	case FileBasicInformation:
		status = DokanSetBasicInformation(
				EventContext, &fileInfo, DokanInstance->DokanOperations);
		break;
		
	case FileDispositionInformation:
		status = DokanSetDispositionInformation(
				EventContext, &fileInfo, DokanInstance->DokanOperations);
		break;
		
	case FileEndOfFileInformation:
		status = DokanSetEndOfFileInformation(
				EventContext, &fileInfo, DokanInstance->DokanOperations);
		break;
		
	case FileLinkInformation:
		status = DokanSetLinkInformation(
				EventContext, &fileInfo, DokanInstance->DokanOperations);
		break;
	
	case FilePositionInformation:
		// this case is dealed with by driver
		status = STATUS_NOT_IMPLEMENTED;
		break;
		
	case FileRenameInformation:
		status = DokanSetRenameInformation(
				EventContext, &fileInfo, DokanInstance->DokanOperations);
		break;

	case FileValidDataLengthInformation:
		status = DokanSetValidDataLengthInformation(
				EventContext, &fileInfo, DokanInstance->DokanOperations);
		break;
	}

	if (openInfo != NULL)
		openInfo->UserContext = fileInfo.Context;
	eventInfo->BufferLength = 0;
	eventInfo->Status = status;

	if (EventContext->Operation.SetFile.FileInformationClass == FileDispositionInformation) {
		if (status == STATUS_SUCCESS) {
			PFILE_DISPOSITION_INFORMATION dispositionInfo =
				(PFILE_DISPOSITION_INFORMATION)((PCHAR)EventContext + EventContext->Operation.SetFile.BufferOffset);
			eventInfo->Operation.Delete.DeleteOnClose = dispositionInfo->DeleteFile ? TRUE : FALSE;
			DbgPrint("  dispositionInfo->DeleteFile = %d\n", dispositionInfo->DeleteFile);
		}

	} else {
		// notice new file name to driver
		if (status == STATUS_SUCCESS && EventContext->Operation.SetFile.FileInformationClass == FileRenameInformation) {
			PDOKAN_RENAME_INFORMATION renameInfo =
				(PDOKAN_RENAME_INFORMATION)((PCHAR)EventContext + EventContext->Operation.SetFile.BufferOffset);
			eventInfo->BufferLength = renameInfo->FileNameLength;
			CopyMemory(eventInfo->Buffer, renameInfo->FileName, renameInfo->FileNameLength);
		}
	}

	//DbgPrint("SetInfomation status = %d\n\n", status);

	SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);
	free(eventInfo);
	return;
}
Example #25
0
bool CTunerBankCtrl::RecStart(const TUNER_RESERVE& reserve, __int64 now) const
{
	if( this->hTunerProcess == NULL ){
		return false;
	}
	if( reserve.recMode == RECMODE_VIEW ){
		return true;
	}
	CSendCtrlCmd ctrlCmd;
	ctrlCmd.SetPipeSetting(CMD2_VIEW_CTRL_WAIT_CONNECT, CMD2_VIEW_CTRL_PIPE, this->tunerPid);
	bool isMainCtrl = true;
	for( int i = 0; i < 2; i++ ){
		if( reserve.ctrlID[i] != 0 ){
			SET_CTRL_REC_PARAM param;
			param.ctrlID = reserve.ctrlID[i];
			//saveFolder[].recFileNameが空でない限りこのフィールドが利用されることはない
			param.fileName = L"padding.ts";
			//同時出力用ファイル名
			param.saveFolder = i == 0 ? reserve.recFolder : reserve.partialRecFolder;
			if( param.saveFolder.empty() ){
				param.saveFolder.resize(1);
				wstring commonIniPath;
				GetCommonIniPath(commonIniPath);
				GetRecFolderPath(param.saveFolder[0].recFolder);
				param.saveFolder[0].writePlugIn = GetPrivateProfileToString(L"SET", L"RecWritePlugIn0", L"", commonIniPath.c_str());
				param.saveFolder[0].recNamePlugIn = this->recNamePlugInFileName;
			}else{
				for( size_t j = 0; j < param.saveFolder.size(); j++ ){
					if( CompareNoCase(param.saveFolder[j].recFolder, L"!Default") == 0 ){
						//注意: この置換は原作にはない
						GetRecFolderPath(param.saveFolder[j].recFolder);
					}
					if( param.saveFolder[j].recNamePlugIn.empty() ){
						param.saveFolder[j].recNamePlugIn = this->recNamePlugInFileName;
					}
				}
			}
			//recNamePlugInを展開して実ファイル名をセット
			for( size_t j = 0; j < param.saveFolder.size(); j++ ){
				param.saveFolder[j].recFileName.clear();
				if( param.saveFolder[j].recNamePlugIn.empty() == false ){
					WORD sid = reserve.sid;
					WORD eid = reserve.eid;
					wstring stationName = reserve.stationName;
					if( i != 0 ){
						FindPartialService(reserve.onid, reserve.tsid, reserve.sid, &sid, &stationName);
						eid = 0xFFFF;
					}
					wstring plugInPath;
					GetModuleFolderPath(plugInPath);
					plugInPath += L"\\RecName\\";
					{
						PLUGIN_RESERVE_INFO info;
						ConvertSystemTime(reserve.startTime, &info.startTime);
						info.durationSec = reserve.durationSecond;
						wcscpy_s(info.eventName, reserve.title.c_str());
						info.ONID = reserve.onid;
						info.TSID = reserve.tsid;
						info.SID = sid;
						info.EventID = eid;
						wcscpy_s(info.serviceName, stationName.c_str());
						wcscpy_s(info.bonDriverName, this->bonFileName.c_str());
						info.bonDriverID = this->tunerID >> 16;
						info.tunerID = this->tunerID & 0xFFFF;
						EPG_EVENT_INFO* epgInfo = NULL;
						if( info.EventID != 0xFFFF ){
							EPGDB_EVENT_INFO epgDBInfo;
							if( this->epgDBManager.SearchEpg(info.ONID, info.TSID, info.SID, info.EventID, &epgDBInfo) != FALSE ){
								epgInfo = new EPG_EVENT_INFO;
								CopyEpgInfo(epgInfo, &epgDBInfo);
							}
						}
						info.reserveID = reserve.reserveID;
						info.epgInfo = epgInfo;
						info.sizeOfStruct = 0;
						WCHAR name[512];
						DWORD size = 512;
						if( CReNamePlugInUtil::ConvertRecName3(&info, param.saveFolder[j].recNamePlugIn.c_str(), plugInPath.c_str(), name, &size) ){
							param.saveFolder[j].recFileName = name;
							CheckFileName(param.saveFolder[j].recFileName, this->recNameNoChkYen);
						}
						delete epgInfo;
					}
					param.saveFolder[j].recNamePlugIn.clear();
				}
				//実ファイル名は空にしない
				if( param.saveFolder[j].recFileName.empty() ){
					SYSTEMTIME st;
					ConvertSystemTime(max(reserve.startTime, now), &st);
					Format(param.saveFolder[j].recFileName, L"%04d%02d%02d%02d%02d%02X%02X%02d-%s.ts",
					       st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute,
					       this->tunerID >> 16, this->tunerID & 0xFFFF, param.ctrlID, reserve.title.c_str());
					CheckFileName(param.saveFolder[j].recFileName);
				}
			}
Example #26
0
bool CKSLog::SaveFileHead(bool bForceSave)

{



	if(m_fp == NULL)

	{

		return false;

	}



	if(m_nOpenMode != LOG_OPENFORWRITE)

	{

		return true;

	}

	

	if (bForceSave==false) 

   {

		return true;

	}



	int  nFileOffset = ftell(m_fp);





/* ****** Updated by CHENYH at 2004-3-31 22:02:09 ****** 

   防止是否在别的平台中,如下赋值会有问题?

	ST_LOGHEAD TmpHead = m_stHead;

*/

   ST_LOGHEAD TmpHead;

   memcpy(&TmpHead,&m_stHead,sizeof(ST_LOGHEAD));



	char	szFilePassword[12];

	char	szCryptPassword[12];

	//memset(szFilePassword, 0, sizeof(szFilePassword));
Example #27
0
BOOL CBatManager::CreateBatFile(BAT_WORK_INFO* info, wstring batSrcFilePath, wstring& batFilePath )
{
	if( info == NULL ){
		return FALSE;
	}
	GetModuleFolderPath(batFilePath);
	batFilePath+=L"\\EpgTimer_Bon_RecEnd.bat";

	//バッチの作成
	HANDLE hRead = CreateFileW( batSrcFilePath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
	if( hRead == INVALID_HANDLE_VALUE ){
		return FALSE;
	}
	HANDLE hWrite = _CreateFile2( batFilePath.c_str(), GENERIC_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
	if( hWrite == INVALID_HANDLE_VALUE ){
		CloseHandle(hRead);
		return FALSE;
	}

	DWORD dwRead=0;
	DWORD dwL = GetFileSize(hRead, NULL);
	char* pBuff = new char[dwL+1];
	ZeroMemory(pBuff, dwL+1);
	ReadFile(hRead, pBuff, dwL, &dwRead, NULL );
	CloseHandle(hRead);

	string strRead = "";
	strRead = pBuff;
	SAFE_DELETE_ARRAY(pBuff);

	string strRecFilePath="";
	string strFolderPath="";
	string strFileName="";
	string strTitle="";
	string strSDYYYY="";
	string strSDYY="";
	string strSDMM="";
	string strSDM="";
	string strSDDD="";
	string strSDD="";
	string strSDW="";
	string strSTHH="";
	string strSTH="";
	string strSTMM="";
	string strSTM="";
	string strSTSS="";
	string strSTS="";
	string strEDYYYY="";
	string strEDYY="";
	string strEDMM="";
	string strEDM="";
	string strEDDD="";
	string strEDD="";
	string strEDW="";
	string strETHH="";
	string strETH="";
	string strETMM="";
	string strETM="";
	string strETSS="";
	string strETS="";
	string strONID10="";
	string strTSID10="";
	string strSID10="";
	string strEID10="";
	string strONID16="";
	string strTSID16="";
	string strSID16="";
	string strEID16="";
	string strServiceName="";
	string strSDYYYY28="";
	string strSDYY28="";
	string strSDMM28="";
	string strSDM28="";
	string strSDDD28="";
	string strSDD28="";
	string strSDW28="";
	string strSTHH28="";
	string strSTH28="";
	string strEDYYYY28="";
	string strEDYY28="";
	string strEDMM28="";
	string strEDM28="";
	string strEDDD28="";
	string strEDD28="";
	string strEDW28="";
	string strETHH28="";
	string strETH28="";
	string strDUH="";
	string strDUHH="";
	string strDUM="";
	string strDUMM="";
	string strDUS="";
	string strDUSS="";
	string strTitle2="";
	string strDrops="";
	string strScrambles="";
	string strResult="";
	string strTitleF="";
	string strTitle2F="";
	string strAddKey="";

	WtoA(info->recFileInfo.recFilePath, strRecFilePath);

	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	WCHAR szPath[_MAX_PATH] = L"";
	_tsplitpath_s( info->recFileInfo.recFilePath.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_tmakepath_s( szPath, _MAX_PATH, szDrive, szDir, NULL, NULL );
	wstring strFolder;
	strFolder = szPath;
	ChkFolderPath(strFolder);

	WtoA(szFname, strFileName);
	WtoA(strFolder, strFolderPath);
	WtoA(info->recFileInfo.title, strTitle);

	Format(strSDYYYY, "%04d", info->recFileInfo.startTime.wYear);
	Format(strSDYY, "%02d", info->recFileInfo.startTime.wYear%100);
	Format(strSDMM, "%02d", info->recFileInfo.startTime.wMonth);
	Format(strSDM, "%d", info->recFileInfo.startTime.wMonth);
	Format(strSDDD, "%02d", info->recFileInfo.startTime.wDay);
	Format(strSDD, "%d", info->recFileInfo.startTime.wDay);
	GetDayOfWeekString2(info->recFileInfo.startTime, strSDW);
	Format(strSTHH, "%02d", info->recFileInfo.startTime.wHour);
	Format(strSTH, "%d", info->recFileInfo.startTime.wHour);
	Format(strSTMM, "%02d", info->recFileInfo.startTime.wMinute);
	Format(strSTM, "%d", info->recFileInfo.startTime.wMinute);
	Format(strSTSS, "%02d", info->recFileInfo.startTime.wSecond);
	Format(strSTS, "%d", info->recFileInfo.startTime.wSecond);

	SYSTEMTIME t28TimeS;
	if( 0 <= info->recFileInfo.startTime.wHour && info->recFileInfo.startTime.wHour < 4 ){
		GetSumTime(info->recFileInfo.startTime, -24*60*60, &t28TimeS);
		GetDayOfWeekString2(t28TimeS, strSDW28);
		t28TimeS.wHour+=24;
	}else{
		t28TimeS = info->recFileInfo.startTime;
		GetDayOfWeekString2(t28TimeS, strSDW28);
	}

	Format(strSDYYYY28, "%04d", t28TimeS.wYear);
	Format(strSDYY28, "%02d", t28TimeS.wYear%100);
	Format(strSDMM28, "%02d", t28TimeS.wMonth);
	Format(strSDM28, "%d", t28TimeS.wMonth);
	Format(strSDDD28, "%02d", t28TimeS.wDay);
	Format(strSDD28, "%d", t28TimeS.wDay);
	Format(strSTHH28, "%02d", t28TimeS.wHour);
	Format(strSTH28, "%d", t28TimeS.wHour);

	SYSTEMTIME tEnd;
	GetI64Time(info->recFileInfo.startTime, info->recFileInfo.durationSecond, NULL, NULL, &tEnd);

	Format(strEDYYYY, "%04d", tEnd.wYear);
	Format(strEDYY, "%02d", tEnd.wYear%100);
	Format(strEDMM, "%02d", tEnd.wMonth);
	Format(strEDM, "%d", tEnd.wMonth);
	Format(strEDDD, "%02d", tEnd.wDay);
	Format(strEDD, "%d", tEnd.wDay);
	GetDayOfWeekString2(tEnd, strEDW);
	Format(strETHH, "%02d", tEnd.wHour);
	Format(strETH, "%d", tEnd.wHour);
	Format(strETMM, "%02d", tEnd.wMinute);
	Format(strETM, "%d", tEnd.wMinute);
	Format(strETSS, "%02d", tEnd.wSecond);
	Format(strETS, "%d", tEnd.wSecond);

	SYSTEMTIME t28TimeE;
	if( 0 <= tEnd.wHour && tEnd.wHour < 4 ){
		GetSumTime(tEnd, -24*60*60, &t28TimeE);
		GetDayOfWeekString2(t28TimeE, strEDW28);
		t28TimeE.wHour+=24;
	}else{
		t28TimeE = tEnd;
		GetDayOfWeekString2(tEnd, strEDW28);
	}

	Format(strEDYYYY28, "%04d", t28TimeE.wYear);
	Format(strEDYY28, "%02d", t28TimeE.wYear%100);
	Format(strEDMM28, "%02d", t28TimeE.wMonth);
	Format(strEDM28, "%d", t28TimeE.wMonth);
	Format(strEDDD28, "%02d", t28TimeE.wDay);
	Format(strEDD28, "%d", t28TimeE.wDay);
	Format(strETHH28, "%02d", t28TimeE.wHour);
	Format(strETH28, "%d", t28TimeE.wHour);

	Format(strONID10, "%d", info->recFileInfo.originalNetworkID);
	Format(strTSID10, "%d", info->recFileInfo.transportStreamID);
	Format(strSID10, "%d", info->recFileInfo.serviceID);
	Format(strEID10, "%d", info->recFileInfo.eventID);
	Format(strONID16, "%04X", info->recFileInfo.originalNetworkID);
	Format(strTSID16, "%04X", info->recFileInfo.transportStreamID);
	Format(strSID16, "%04X", info->recFileInfo.serviceID);
	Format(strEID16, "%04X", info->recFileInfo.eventID);

	WtoA(info->recFileInfo.serviceName, strServiceName);

	Format(strDUHH, "%02d", info->recFileInfo.durationSecond/(60*60));
	Format(strDUH, "%d", info->recFileInfo.durationSecond/(60*60));
	Format(strDUMM, "%02d", (info->recFileInfo.durationSecond%(60*60))/60);
	Format(strDUM, "%d", (info->recFileInfo.durationSecond%(60*60))/60);
	Format(strDUSS, "%02d", info->recFileInfo.durationSecond%60);
	Format(strDUS, "%d", info->recFileInfo.durationSecond%60);

	wstring strTemp = info->recFileInfo.title;
	while( (strTemp.find(L"[") != string::npos) && (strTemp.find(L"]") != string::npos) ){
		wstring strSep1=L"";
		wstring strSep2=L"";
		Separate(strTemp, L"[", strSep1, strTemp);
		Separate(strTemp, L"]", strSep2, strTemp);
		strSep1 += strTemp;
		strTemp = strSep1;
	}
	WtoA(strTemp, strTitle2);

	Format(strDrops, "%I64d", info->recFileInfo.drops);
	Format(strScrambles, "%I64d", info->recFileInfo.scrambles);
	WtoA(info->recFileInfo.comment, strResult);

	CheckFileName(strTitleF);
	CheckFileName(strTemp);
	WtoA(strTemp, strTitle2F);
	strTemp = info->recFileInfo.title;
	CheckFileName(strTemp);
	WtoA(strTemp, strTitleF);

	if( info->reserveInfo.comment.find(L"EPG自動予約(") != string::npos ){
		WtoA(info->reserveInfo.comment, strAddKey);
		Replace(strAddKey, "EPG自動予約(", "");
		strAddKey.erase(strAddKey.length()-1, 1);
	}

	Replace(strRead, "$FilePath$", strRecFilePath);
	Replace(strRead, "$FolderPath$", strFolderPath);
	Replace(strRead, "$FileName$", strFileName);
	Replace(strRead, "$Title$", strTitle);
	Replace(strRead, "$SDYYYY$", strSDYYYY);
	Replace(strRead, "$SDYY$", strSDYY);
	Replace(strRead, "$SDMM$", strSDMM);
	Replace(strRead, "$SDM$", strSDM);
	Replace(strRead, "$SDDD$", strSDDD);
	Replace(strRead, "$SDD$", strSDD);
	Replace(strRead, "$SDW$", strSDW);
	Replace(strRead, "$STHH$", strSTHH);
	Replace(strRead, "$STH$", strSTH);
	Replace(strRead, "$STMM$", strSTMM);
	Replace(strRead, "$STM$", strSTM);
	Replace(strRead, "$STSS$", strSTSS);
	Replace(strRead, "$STS$", strSTS);
	Replace(strRead, "$EDYYYY$", strEDYYYY);
	Replace(strRead, "$EDYY$", strEDYY);
	Replace(strRead, "$EDMM$", strEDMM);
	Replace(strRead, "$EDM$", strEDM);
	Replace(strRead, "$EDDD$", strEDDD);
	Replace(strRead, "$EDD$", strEDD);
	Replace(strRead, "$EDW$", strEDW);
	Replace(strRead, "$ETHH$", strETHH);
	Replace(strRead, "$ETH$", strETH);
	Replace(strRead, "$ETMM$", strETMM);
	Replace(strRead, "$ETM$", strETM);
	Replace(strRead, "$ETSS$", strETSS);
	Replace(strRead, "$ETS$", strETS);
	Replace(strRead, "$ONID10$", strONID10);
	Replace(strRead, "$TSID10$", strTSID10);
	Replace(strRead, "$SID10$", strSID10);
	Replace(strRead, "$EID10$", strEID10);
	Replace(strRead, "$ONID16$", strONID16);
	Replace(strRead, "$TSID16$", strTSID16);
	Replace(strRead, "$SID16$", strSID16);
	Replace(strRead, "$EID16$", strEID16);
	Replace(strRead, "$ServiceName$", strServiceName);
	Replace(strRead, "$SDYYYY28$", strSDYYYY28);
	Replace(strRead, "$SDYY28$", strSDYY28);
	Replace(strRead, "$SDMM28$", strSDMM28);
	Replace(strRead, "$SDM28$", strSDM28);
	Replace(strRead, "$SDDD28$", strSDDD28);
	Replace(strRead, "$SDD28$", strSDD28);
	Replace(strRead, "$SDW28$", strSDW28);
	Replace(strRead, "$STHH28$", strSTHH28);
	Replace(strRead, "$STH28$", strSTH28);
	Replace(strRead, "$EDYYYY28$", strEDYYYY28);
	Replace(strRead, "$EDYY28$", strEDYY28);
	Replace(strRead, "$EDMM28$", strEDMM28);
	Replace(strRead, "$EDM28$", strEDM28);
	Replace(strRead, "$EDDD28$", strEDDD28);
	Replace(strRead, "$EDD28$", strEDD28);
	Replace(strRead, "$EDW28$", strEDW28);
	Replace(strRead, "$ETHH28$", strETHH28);
	Replace(strRead, "$ETH28$", strETH28);
	Replace(strRead, "$DUHH$", strDUHH);
	Replace(strRead, "$DUH$", strDUH);
	Replace(strRead, "$DUMM$", strDUMM);
	Replace(strRead, "$DUM$", strDUM);
	Replace(strRead, "$DUSS$", strDUSS);
	Replace(strRead, "$DUS$", strDUS);
	Replace(strRead, "$Title2$", strTitle2);
	Replace(strRead, "$Drops$", strDrops);
	Replace(strRead, "$Scrambles$", strScrambles);
	Replace(strRead, "$Result$", strResult);
	Replace(strRead, "$TitleF$", strTitleF);
	Replace(strRead, "$Title2F$", strTitle2F);
	Replace(strRead, "$AddKey$", strAddKey);

	DWORD dwWrite=0;
	WriteFile(hWrite, strRead.c_str(), (DWORD)strRead.length(), &dwWrite, NULL );
	CloseHandle(hWrite);

	return TRUE;
}
Example #28
0
VOID
DispatchLock(
	HANDLE				Handle,
	PEVENT_CONTEXT		EventContext,
	PDOKAN_INSTANCE		DokanInstance)
{
	DOKAN_FILE_INFO		fileInfo;
	PEVENT_INFORMATION	eventInfo;
	ULONG				sizeOfEventInfo = sizeof(EVENT_INFORMATION);
	PDOKAN_OPEN_INFO	openInfo;
	int status;

	CheckFileName(EventContext->Lock.FileName);

	eventInfo = DispatchCommon(
		EventContext, sizeOfEventInfo, DokanInstance, &fileInfo, &openInfo);

	logw(L"###Lock %04d\n", openInfo != NULL ? openInfo->EventId : -1);

	eventInfo->Status = STATUS_NOT_IMPLEMENTED;

	switch (EventContext->MinorFunction) {
	case IRP_MN_LOCK:
		if (DokanInstance->DokanOperations->LockFile) {

			status = DokanInstance->DokanOperations->LockFile(
						EventContext->Lock.FileName,
						EventContext->Lock.ByteOffset.QuadPart,
						EventContext->Lock.Length.QuadPart,
						//EventContext->Lock.Key,
						&fileInfo);

			eventInfo->Status = status < 0 ?
				STATUS_LOCK_NOT_GRANTED : STATUS_SUCCESS;
		}
		break;
	case IRP_MN_UNLOCK_ALL:
		break;
	case IRP_MN_UNLOCK_ALL_BY_KEY:
		break;
	case IRP_MN_UNLOCK_SINGLE:
		if (DokanInstance->DokanOperations->UnlockFile) {
		
			status = DokanInstance->DokanOperations->UnlockFile(
						EventContext->Lock.FileName,
						EventContext->Lock.ByteOffset.QuadPart,
						EventContext->Lock.Length.QuadPart,
						//EventContext->Lock.Key,
						&fileInfo);

			eventInfo->Status = STATUS_SUCCESS; // at any time return success ?
		}
		break;
	default:
		logw(L"unkown lock function %d\n", EventContext->MinorFunction);
	}

	openInfo->UserContext = fileInfo.Context;

	SendEventInformation(Handle, eventInfo, sizeOfEventInfo, DokanInstance);

	free(eventInfo);
	return;
}