⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pfwinfile.cpp

📁 PowerFish is a class library, intended to provide a broad functionality base for any application. Al
💻 CPP
字号:
/////////////////////////////////////////////////////////////////////////////////////////////////////// PowerFish core library// Copyright (C) 1997-2001 Camilla Drefvenborg <elmindreda@home.se>//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA/////////////////////////////////////////////////////////////////////////////////////////////////////#include <PfBase.h>#include <PfTemplate.h>#include <PfString.h>#include <PfStream.h>#include <PfFile.h>#include <windows.h>#include "PfWinFileStream.h"///////////////////////////////////////////////////////////////////////////////////////////////////PfStream* PfOpenFile(const char* szPathName, bool bAllowCreate, bool bAllowRead, bool bAllowWrite){	PFASSERT(szPathName);	PfWinFileStream* pStream = new PfWinFileStream();	if (!pStream->Open(szPathName, bAllowCreate, bAllowRead, bAllowWrite))	{		delete pStream;		pStream = NULL;		return false;	}	return pStream;}PfStream* PfCreateFile(const char* szPathName, bool bAllowExist, bool bAllowRead, bool bAllowWrite){	PFASSERT(szPathName);	PfWinFileStream* pStream = new PfWinFileStream();	if (!pStream->Create(szPathName, bAllowExist, bAllowRead, bAllowWrite))	{		delete pStream;		pStream = NULL;		return false;	}	return pStream;}bool PfCopyFile(const char* szOldPathName, const char* szNewPathName){	PFASSERT(szOldPathName);	PFASSERT(szNewPathName);	if (!CopyFile(szOldPathName, szNewPathName, FALSE))		return false;	return true;}bool PfMoveFile(const char* szOldPathName, const char* szNewPathName){	PFASSERT(szOldPathName);	PFASSERT(szNewPathName);	if (!MoveFile(szOldPathName, szNewPathName))		return false;	return true;}bool PfDestroyFile(const char* szPathName){	PFASSERT(szPathName);	if (!DeleteFile(szPathName))		return false;	return true;}bool PfIsFile(const char* szPathName){	PFASSERT(szPathName);	DWORD dwAttributes = GetFileAttributes(szPathName);	if (dwAttributes == (DWORD) -1)		return false;	if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)		return false;	return true;}bool PfGetFileInfo(const char* szPathName, PfFileInfo& rInfo){	PFASSERT(szPathName);	DWORD dwAttributes = GetFileAttributes(szPathName);	if (dwAttributes == (DWORD) -1)		return false;	if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)		return false;	rInfo.m_Name        = PfGetFilePart(szPathName);	rInfo.m_Path        = szPathName;	rInfo.m_bAllowRead  = true;	rInfo.m_bAllowWrite = dwAttributes & FILE_ATTRIBUTE_READONLY ? false : true;	return true;}const char* PfRequestUserOpenFileSelection(void){	// TODO: make thread safe!	static char szFileName[_MAX_PATH + 1];	OPENFILENAME ofn;	ZeroMemory(&ofn, sizeof(OPENFILENAME));	ofn.lStructSize  = sizeof(OPENFILENAME);	ofn.lpstrFilter  = "All files\0*.*\0";	ofn.nFilterIndex = 0;	ofn.lpstrFile    = szFileName;	ofn.nMaxFile     = sizeof(szFileName);	ofn.Flags        = OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;	ofn.lpstrDefExt  = "log";	ofn.hwndOwner    = GetActiveWindow();	if (!GetOpenFileName(&ofn))		return NULL;	return szFileName;}const char* PfRequestUserSaveFileSelection(void){	// TODO: make thread safe!	static char szFileName[_MAX_PATH + 1];	OPENFILENAME ofn;	ZeroMemory(&ofn, sizeof(OPENFILENAME));	ofn.lStructSize  = sizeof(OPENFILENAME);	ofn.lpstrFilter  = "All files\0*.*\0";	ofn.nFilterIndex = 0;	ofn.lpstrFile    = szFileName;	ofn.nMaxFile     = sizeof(szFileName);	ofn.Flags        = OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;	ofn.lpstrDefExt  = "log";	ofn.hwndOwner    = GetActiveWindow();	if (!GetSaveFileName(&ofn))		return NULL;	return szFileName;}///////////////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -