📄 eccfile.h
字号:
/* ==========================================================================
Ecc - Erik's Code Collection
Copyright (C) 2003 - Erik Dienske
This file is part of Ecc.
Ecc 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.
Ecc 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 Ecc; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
===========================================================================*/
//---------------------------------------------------------------------------
#ifndef EccFileH
#define EccFileH
//---------------------------------------------------------------------------
//===========================================================================
namespace ecc {
//===========================================================================
//---------------------------------------------------------------------------
bool MakeFileList(String path, TStringList* list, const bool include_path = true);
/* Adds absolute paths of all files in <path> to <list>.
Or, if <include_path> is false: adds relative paths of all files in <path> to <list>.
Returns false if an error occured. */
bool MakeDirList(String path, TStringList* list);
/* Adds absolute paths of all directories in <path> to <list>.
Returns false if an error occured. */
bool MakeRelativeDirList(String path, TStringList* list);
/* Adds relative paths of all directories in <path> to <list>.
Returns false if an error occured. */
bool StringToFile(const String str, const String fname);
String FileToString(const String fname);
String ExtractFileNameNoExt(String fname);
/* Returns fname without path and extension. */
String ReplaceIllegalFileNameChars(String fname, const String replace = "");
long GetFileSize(const String fname);
/* Returns -1 if size could not be read. */
String FloatToHumanFileSize(float fsize);
/* Returns human readable filesize. In B, kB, MB or GB.
Returns "?" if size<0. */
String FileAttributeStr(const String fname);
/* Returns a string like: "AH".
Returns an empty string if fname is a directory. */
void AddDoubleZeroToString(String &fname);
bool FileToRecycleBin(String fpath);
/* Returns false on failure. */
bool MoveFile(String src_fname, String dest_fname);
/* Returns false on failure. */
TDateTime FILETIMEToTDateTime(const FILETIME ftime);
/* Converts a windows FILETIME structure to a Borland TDateTime class.
Drawback: TDateTime (==DosDateTime) is less accurate than FILETIME.
On error: return value is TDateTime(1911, 11, 11). */
bool CreateFileAssociation(String ext, String file_type_str,
String app_name, String app_path,
bool click_start);
/* Creates a file association for files with <ext> as extension.
Returns false if an error occured.
<ext> includes the dot.
<file_type_str> String that describes the file type.
<app_name> Name of the application. Will be stored in the registry.
<app_path> Full path to the application.
<click_start> If true, clicking the file.ext will open app_path. */
void AppendStrToFile(String msg, String fpath, bool include_datetime = true);
/* Useful for adding strings to a log file. */
//---------------------------------------------------------------------------
//===========================================================================
} // namespace ecc;
//===========================================================================
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -