- 浏览: 24708 次
- 性别:
- 来自: 东莞
最新评论
-
flythink:
oledb是不是更容易弄一些? 纯猜测
MS ODBC for DMD 2.053 -
hqs7636:
8错,继续完善一下。。。
MS ODBC for DMD 2.053 -
rocex:
lz的这个工具好用,可以随时在1.x和2.x上切换。
DEx ...
D2/Phobos与D2/Tango一键切换编译环境设置 -
Colorful:
链接是这个 : http://code.google.com/ ...
Windows D编程类封装初步学习并请教 -
betty_betty2008:
哥们:链接打不开
Windows D编程类封装初步学习并请教
std.path
This module is used to parse file names. All the operations work only on strings; they don't perform any input/output operations. This means that if a path contains a directory name with a dot, functions like getExt() will work with it just as if it was a file. To differentiate these cases, use the std.file module first (i.e. std.file.isDir()).
该模块操作文件名,所有的操作均针对string,没有输入/输出操作。这意味着假如path是一个包含句点的目录名,则象getExt()这样的方法就会把它当成一个文件.要区分这种情况,先用std.file模块(如std.file.isDir())。
Authors:
作者:
Walter Bright, Grzegorz Adam Hankiewicz, Thomas Kühne, Andrei Alexandrescu
invariant char[1u] sep;
String used to separate directory names in a path. Under Windows this is a backslash, under Linux a slash.
以不变量字符串形式返回目录分隔符。Windows下为 '\' ,Linux 下为 '/' 。
invariant char[1u] altsep;
Alternate version of sep[] used in Windows (a slash). Under Linux this is empty.
以不变量字符串形式返回备选目录分隔符。Windows下为 '/' ,Linux 下为空格 。
invariant char[1u] pathsep;
Path separator string. A semi colon under Windows, a colon under Linux.
以不变量字符串形式返回路径分隔符。Windows下为 ';' , Linux 下为 ':' 。
invariant char[2u] linesep;
String used to separate lines. String used to separate lines, \r\n under Windows and \n under Linux.
以不变量字符串形式返回行分隔符。Windows下为 \r\n ,Linux 下为 \n 。
invariant char[1u] curdir;
String representing the current directory.
以不变量字符串形式返回返回当前目录。
invariant char[2u] pardir;
String representing the parent directory.
以不变量字符串形式返回父目录。
alias fcmp;
Compare file names.
比较文件名。
Returns: 返回值:
< 0
0 filename1 == filename2 //文件名相同
> 0
string getExt(string fullname);
Extracts the extension from a filename or path.
以字符串形式从文件名或路径中返回文件扩展名。
This function will search fullname from the end until the first dot, path separator or first character of fullname is reached. Under Windows, the drive letter separator (colon) also terminates the search.
该方法在fullname中自尾向前查找,直至遇到的第一个句点 、路径分隔符或者第一个字符。Window下遇到磁盘分隔符(:)时终止查找。
Returns:返回值:
If a dot was found, characters to its right are returned. If a path separator was found, or fullname didn't contain any dots or path separators, returns null.
如果找到句点,返回句点之右的字符串;否则,如果找到路径分隔符,或fullname未包含句点或路径分隔符时,均返回null。
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
getExt(r"d:\path\foo.bat") // "bat"
getExt(r"d:\path.two\bar") // null
}
version(Posix)
{
getExt(r"/home/user.name/bar.") // ""
getExt(r"d:\\path.two\\bar") // "two\\bar"
getExt(r"/home/user/.resource") // "resource"
}
string getName(string fullname);
Returns the extensionless version of a filename or path.
以字符串形式返回不包含扩展名的文件名或路径。
This function will search fullname from the end until the first dot, path separator or first character of fullname is reached. Under Windows, the drive letter separator (colon) also terminates the search.
该方法在fullname中自尾向前查找,直至遇到的第一个句点 、路径分隔符或者第一个字符。Window下遇到磁盘分隔符(:)时终止查找。
Returns: 返回值:
If a dot was found, characters to its left are returned. If a path separator was found, or fullname didn't contain any dots or path separators, returns null.
如果找到句点,返回句点之左的字符串;否则,如果找到路径分隔符,或fullname未包含句点或路径分隔符时,均返回null。
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
getName(r"d:\path\foo.bat") => "d:\path\foo"
getName(r"d:\path.two\bar") => null
}
version(Posix)
{
getName("/home/user.name/bar.") => "/home/user.name/bar"
getName(r"d:\path.two\bar") => "d:\path"
getName("/home/user/.resource") => "/home/user/"
}
string basename(string fullname, string extension = null);
Extracts the base name of a path and optionally chops off a specific suffix.
自一个路径中提取基本文件名,并截掉后缀(如有)。
This function will search fullname from the end until the first path separator or first character of fullname is reached. Under Windows, the drive letter separator (colon) also terminates the search. After the search has ended, keep the portion to the right of the separator if found, or the entire fullname otherwise. If the kept portion has suffix extension, remove that suffix. Return the remaining string.
该方法在fullname中自尾向前查找,直至遇到的第一个路径分隔符或者第一个字符。Window下遇到磁盘分隔符(:)时终止查找。如果找到路径分隔符,保留分隔符之后的部分;否则返回整个fullname.如果分隔符之右的部门包含后缀扩展名,移除后缀再返回剩余部分字符串。
Returns:返回值:
The portion of fullname left after the path part and the extension part, if any, have been removed.
返回fullname之中最后一个分隔符与扩展名(如有,被移除)之间的部分。
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
basename(r"d:\path\foo.bat") => "foo.bat"
basename(r"d:\path\foo", ".bat") => "foo"
}
version(Posix)
{
basename("/home/user.name/bar.") => "bar."
basename("/home/user.name/bar.", ".") => "bar"
}
alias getBaseName;
Alias for basename, kept for backward compatibility. New code should use basename.
Basename方法的别名,为向后兼容而保留,新代码应该使用basename方法。
Char[] dirname(Char)(Char[] fullname);
Extracts the directory part of a path.
提取路径中的目录名。
This function will search fullname from the end until the first path separator or first character of fullname is reached. Under Windows, the drive letter separator (colon) also terminates the search.
该方法在fullname中自尾向前查找,直至遇到的第一个路径分隔符或者第一个字符。Window下遇到磁盘分隔符(:)时终止查找。
Returns:
If a path separator was found, all the characters to its left are returned. Otherwise, "." is returned.
如果找到路径分隔符,其左边所有字符被返回;否则返回"."。
Under Windows, the found path separator will be included in the returned string if it is preceeded by a colon.
Windows下紧跟在磁盘分隔符(:)之后的路径分隔符包含则返回值中。
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
assert(dirname(r"d:\path\foo.bat") == r"d:\path");
assert(dirname(dirname(r"d:\path\foo.bat")) == r"d:\");
}
version(Posix)
{
assert(dirname("/home/user") == "/home");
assert(dirname(dirname("/home/user")) == "");
}
alias getDirName;
Alias for dirname, kept for backward compatibility. New code should use dirname.
dirname方法的别名,为向后兼容而保留,新代码应该使用dirname方法。
String getDrive(String)(String fullname);
Extracts the drive letter of a path.
提取路径中的盘符。
This function will search fullname for a colon from the beginning.
该方法在fullname中从头开始查找冒号(:)。
Returns:返回值:
If a colon is found, all the characters to its left plus the colon are returned. Otherwise, null is returned.
如找到冒号(:),其左边所字符连同其本身一起返回,如未找到则返回null。
Under Linux, this function always returns null immediately.
Linux下该方法只会返回null。
Throws:抛出异常:
Nothing. 无
Examples:示例:
getDrive(r"d:\path\foo.bat") => "d:"
string defaultExt(string filename, string ext);
Appends a default extension to a filename.
给filename添加默认扩展名。
This function first searches filename for an extension and appends ext if there is none. ext should not have any leading dots, one will be inserted between filename and ext if filename doesn't already end with one.
该方法首先在filename中查找扩展名,如未找到则添加ext为其扩展名。ext不能有前导句点,如filename末尾有句点,直接添加ext;如filename末尾无句点,则添加句点+ext。
Returns:返回值:
filename if it contains an extension, otherwise filename + ext.
如filename已包含扩展名,则返回filename;否则返回filename+ext。
Throws:抛出异常:
Nothing. 无
Examples:示例:
defaultExt("foo.txt", "raw") => "foo.txt"
defaultExt("foo.", "raw") => "foo.raw"
defaultExt("bar", "raw") => "bar.raw"
string addExt(string filename, string ext);
Adds or replaces an extension to a filename.
给filename添加或替换扩展名。
This function first searches filename for an extension and replaces it with ext if found. If there is no extension, ext will be appended. ext should not have any leading dots, one will be inserted between filename and ext if filename doesn't already end with one.
该方法首先在filename中查找扩展名,如找到则用ext替换原扩展名;如未找到则添加ext为其扩展名,添加时ext不能有前导句点,如filename末尾有句点,直接添加ext;如filename末尾无句点,则添加句点+ext。
Returns:返回值:
filename + ext if filename is extensionless. Otherwise strips filename's extension off, appends ext and returns the result.
如filename无扩展名,返回filename+ext;否则去掉扩展名,添加ext为其扩展名然后返回整个字符串。
Throws:抛出异常:
Nothing. 无
Examples:示例:
addExt("foo.txt", "raw") => "foo.raw"
addExt("foo.", "raw") => "foo.raw"
addExt("bar", "raw") => "bar.raw"
bool isabs(in char[] path);
Checks if path is absolute.
检查path是否为绝对路径。
Returns:返回值:
non-zero if the path starts from the root directory (Linux) or drive letter and root directory (Windows), zero otherwise.
Linux下如果path以根目录开始,返回非零值,Windows下如果path以盘符+根目录开始,返回非零值;否则返回0。
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
isabs(r"relative\path") => 0
isabs(r"\relative\path") => 0
isabs(r"d:\absolute") => 1
}
version(Posix)
{
isabs("/home/user") => 1
isabs("foo") => 0
}
string rel2abs(string path);
Converts a relative path into an absolute path.
把相对路径path转换为绝对路径。
string join(in char[] p1, in char[] p2, in char[][] more...);
Joins two or more path components.
把两个及以上路径p1,p2…more 连接成一个路径。
If p1 doesn't have a trailing path separator, one will be appended to it before concatenating p2.
如果p1末尾未包含路径分隔符,方法在连接之前添加路径分隔符然后连接。
Returns:返回值:
p1 ~ p2. However, if p2 is an absolute path, only p2 will be returned.
如果p2为绝对路径,则返回p2;否则返回p1~p2…. 。
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
join(r"c:\foo", "bar") => r"c:\foo\bar"
join("foo", r"d:\bar") => r"d:\bar"
}
version(Posix)
{
join("/foo/", "bar") => "/foo/bar"
join("/foo", "/bar") => "/bar"
}
bool fncharmatch(dchar c1, dchar c2);
Matches filename characters.
对比匹配文件名字符。
Under Windows, the comparison is done ignoring case. Under Linux an exact match is performed.
对比时Windows下不区分大小写;Linux下区分大小写。
Returns:返回值:
non zero if c1 matches c2, zero otherwise.
匹配返回非零值,否则返回0。
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
fncharmatch('a', 'b') => 0
fncharmatch('A', 'a') => 1
}
version(Posix)
{
fncharmatch('a', 'b') => 0
fncharmatch('A', 'a') => 0
}
bool fnmatch(in char[] filename, in char[] pattern);
Matches a pattern against a filename.
在filename中匹配pattern。
Some characters of pattern have special a meaning (they are meta-characters) and can't be escaped. These are:
有些字符含有特殊的意义(它们是元字符),不能转义。它们是:
*
?
[chars] [字符]
[!chars] [!字符]
Internally individual character comparisons are done calling fncharmatch(), so its rules apply here too. Note that path separators and dots don't stop a meta-character from matching further portions of the filename.
方法内部单个字符的比较调用fncharmath(),所有前者的匹配规则在这时也适用。请留意路径分隔符和句点不阻止元字符在filename的后续部分继续匹配。
Returns:返回值:
non zero if pattern matches filename, zero otherwise.
如匹配返回非零值;否则返回0。
See Also:参见:
fncharmatch().
Throws:抛出异常:
Nothing. 无
Examples:示例:
version(Win32)
{
fnmatch("foo.bar", "*") => 1
fnmatch(r"foo/foo\bar", "f*b*r") => 1
fnmatch("foo.bar", "f?bar") => 0
fnmatch("Goo.bar", "[fg]???bar") => 1
fnmatch(r"d:\foo\bar", "d*foo?bar") => 1
}
version(Posix)
{
fnmatch("Go*.bar", "[fg]???bar") => 0
fnmatch("/foo*home/bar", "?foo*bar") => 1
fnmatch("foobar", "foo?bar") => 1
}
string expandTilde(string inputPath);
Performs tilde expansion in paths.
在路径中应用代字符(~)。
There are two ways of using tilde expansion in a path. One involves using the tilde alone or followed by a path separator. In this case, the tilde will be expanded with the value of the environment variable HOME. The second way is putting a username after the tilde (i.e. ~john/Mail). Here, the username will be searched for in the user database (i.e. /etc/passwd on Unix systems) and will expand to whatever path is stored there. The username is considered the string after the tilde ending at the first instance of a path separator.
有两种方法应用代字符。第一种方法是单用代字符~后跟路径分隔符,这种情况代字符将被扩展为系统环境变量HOME的值;第二种方法是代字符后加用户名(即~john/Mail)。这种情况首先将在用户数据库(即 Unix 系统下 /etc/passwd)中查找该用户名,然后扩展为其存贮的实际路径。用户名被认定为代字符与第一个路径分隔符之间的字符串。
Note that using the ~user syntax may give different values from just ~ if the environment variable doesn't match the value stored in the user database.
请留意如果环境变量与存贮在用户数据库中的值不匹配时,使用~user的语法和只用~的结果可能不一致。
When the environment variable version is used, the path won't be modified if the environment variable doesn't exist or it is empty. When the database version is used, the path won't be modified if the user doesn't exist in the database or there is not enough memory to perform the query.
用环境变量版本时,如果环境变量不存在或其值为空,路径不能被修改;用数据库版本时,如用户不存在或查询数据库内存不足时,路径不能被修改。
Returns:返回值:
inputPath with the tilde expanded, or just inputPath if it could not be expanded. For Windows, expandTilde() merely returns its argument inputPath.
代字符扩展后的inputPath,当inputPath不能被扩展时,返回inputPath;Window下仅仅返回inputPath。
Throws:抛出异常:
std.outofmemory.OutOfMemoryException if there is not enough memory to perform the database lookup for the ~user syntax.
使用~user 语法版本时,如果没有足够内存查寻数据库,抛出std.outofmemory.OutOfMemoryException异常。
Examples:示例:
import std.path;
void process_file(string filename)
{
string path = expandTilde(filename);
...
}
import std.path;
string RESOURCE_DIR_TEMPLATE = "~/.applicationrc";
string RESOURCE_DIR; // This gets expanded in main().
int main(string[] args)
{
RESOURCE_DIR = expandTilde(RESOURCE_DIR_TEMPLATE);
...
}
Version:版本:
Available since v0.143.
自v0.143起可用。
Authors:作者:
Grzegorz Adam Hankiewicz, Thomas Kühne.
发表评论
-
D2 下win32 api 中文框架备忘
2011-07-28 17:49 1042隔一段时间就忘了怎么在D2下win32 SDK框架里使用中文, ... -
MS ODBC for DMD 2.053
2011-05-20 16:49 1218东拼西凑,终于在dmd2.053下成功连接上了ODBC 数据库 ... -
截屏、闪屏(Timer)、输入窗口--DFL for D2.053
2011-05-16 17:41 1272这个小练习用D2.053+DFL完成了以下功能: 1.截屏(C ... -
SDK写的一个画树(花)程序
2009-11-23 17:53 1078[img]C:\Documents and Settings\ ... -
json for D2.034
2009-10-13 19:54 719作者:Jeremie Pelletier 链接: [url] ... -
D2 中使用VC的Windows资源文件
2009-09-15 15:26 1226终于试成功了。总结一下: 一.在*.RC里包含window ... -
windows vfw.lib
2009-09-07 20:06 1327上传到这里,因为有时候改变工作地点后另一台机上没有。:P -
Windows D编程类封装初步学习并请教
2009-09-01 18:37 1213首先把要请教的问题写在最顶部: 1。事件最好的包装方法是怎样的 ... -
再学SQLite3 API
2009-08-21 17:48 2237这次进一步看了看SQLigte3 的API,不用上次写的类包装 ... -
"D"iving Into the D Programming Language
2009-08-04 16:23 1586"D"iving Into the D P ... -
练习:boost.timer 转D2
2009-07-21 12:32 1324中间解决了好几个问题,尚有几个问题没解决,已在NG上提问。备忘 ... -
Sqlite3 C++类库Sharplite 转D
2009-07-17 16:32 1658这是一份作业,因为所有创作的部分都是前人的。 材料:1.sql ... -
D2 反射和defineEum! 练习
2009-07-16 14:21 867备忘: module DioApp; imp ... -
D2 std.stream 文件读写小练习
2009-07-13 19:12 1777笔记要点: 1。个人工具包samsTools 工具之一Prom ... -
DFL for DMD2.031
2009-07-10 16:33 907从NG里要到的,俺测过了,OK 的啦. 原贴原下载地址链接: ... -
D2/Phobos与D2/Tango一键切换编译环境设置
2009-05-08 18:01 1167一。适合谁: 象俺一样,反反复复搭不起D编译环境的小菜 二。不 ... -
(翻译)Phobos 2.029 R部 std.random
2009-04-27 14:58 1317std.random ... -
(翻译)Phobos 2.029 P部 std.process
2009-04-23 11:57 1158std.process ...
相关推荐
2. **图像的数字化**:包括采样和量化两个步骤。采样决定了图像的空间分辨率,量化则决定了图像的灰度或色彩级别。 3. **图像的表示与存储**:例如,用二维数组表示图像,常见的有RGB模型和灰度级表示。 4. **图像...
Petabridge.Phobos.Web.InfluxDB 该存储库源自我们在使用的代码所有内容,除了我们选择的外,其他内容大致相同。 注意:此解决方案使用 的 ,您可以在以下位置通过Grafana Cloud将其安装在自己的应用程序中: ://...
Phobos勒索专杀工具是一款专门针对名为Phobos的勒索病毒设计的安全软件。Phobos勒索病毒是一种恶意软件,它通过加密用户的文件并要求支付赎金来解锁,对个人和企业的数据安全构成了严重威胁。这款专杀工具的出现,...
构建完成后,将与文件夹中所使用的构建配置相同的文件夹中的结果Phobos.dll YR目录中,并启动针对您的YR可执行文件(通常为gamemd.exe )的Syringe。 您还可以通过GitHub Actions工作流自动测试特定提交的夜间版本,...
.2700勒索病毒解密工具 phobos解密工具,需要密钥才能解密。上次交了5万元给的解密工具,但是每个机器秘密是不一样的。这是工具!
Phobos是一款与字体相关的压缩包,其名称来源于火星的最大卫星——“火卫一”Phobos。在IT行业中,字体扮演着至关重要的角色,它不仅关乎文本的可读性,还影响着用户界面的美观和用户体验。让我们深入探讨一下Phobos...
### Netty In Action 知识点详述 #### 一、为什么使用Netty? ##### 1.1 高性能与简单易用 - **间接解决问题**:Netty作为一款NIO客户端-服务器框架,遵循David John Wheeler提出的观点——通过添加额外的逻辑层...
例如,如果库有一个名为`phobos.utils`的模块,可以这样导入: ```python from phobos import utils ``` 然后调用模块内的函数或类,如`utils.some_function()`。 **Python 开发语言** Python是一种高级编程语言...
8. **丰富的库支持**:D语言有广泛的库支持,包括标准库Phobos和第三方库Druntime,覆盖了网络、图形、文件I/O等多个领域。 9. **简洁语法**:D语言的语法设计借鉴了其他语言,力求简洁明了,易于理解和学习。 10....
Phobos是一款专门用于检测SSR(Simple Sequence Repeat)微卫星的生物信息学软件。SSR,也称为短串联重复序列,是DNA中的一种常见变异形式,常用于遗传标记和基因定位研究。Phobos软件的出现极大地简化了对这些序列...
GandCrab v5.0.x 那些事儿——行为分析、免疫与救援须知
【标题】"Phobos: MarsRon的Discord.js机器人" Phobos是MarsRon创建的一款基于Discord.js库的机器人,它专为Discord社区设计,提供了丰富的交互功能和自动化服务。Discord.js是一个强大的JavaScript库,使得开发者...
dasocks 使用标准库中的以下模块完全用 D 编写: core.thread、std.socket、std.c.string(标准 C 库)、std.array、std.conv、std.string dasocks 具有以下特点简化的异步socket使用,跨平台,线程管理,使用字符...
的iTunes iTunes API周围的Ruby包装器,可让您搜索iTunes商店中可用的任何类型的数据。 范例回应 { " artist_id " : 954266 , ... " artwork_url30 " : " http://a1.phobos.apple.com/us/r1000/049/Features
`phobos.png` 应该是一个图像文件,可能是游戏中的角色、背景或者游戏元素的图形资源。HTML5的Canvas API可以用来绘制和操作这些图像,从而实现动态的游戏画面。开发者可以通过更换或编辑这个图像来改变游戏的视觉...
2. **构建环境准备**:为了构建 Phobos,开发人员需要安装相应的构建工具,如 Maven 或 Gradle(由于标签为 "Java",我们假设它是用 Java 开发的)。还需要设置 Java Development Kit (JDK) 的环境变量,确保版本...
该模型计算出的结果与UA5,PHOBOS,UA1,P238,CDF,ALICE和CMS协作的实验数据一致,从低到高依次呈现。 根据不同成分的分布宽度,获得了“参与者”和“观众”夸克成分的声音参数cs2的平方值和一些特征。 结果表明...
2. **代码生成**:框架包含工具,能够自动生成类和Web表单,减少了手动编写重复代码的时间。这不仅提高了开发速度,也降低了出错的可能性。 3. **对象关系映射(ORM)**:Phobos提供了持久性层,通过ORM技术将...