检查路径是否为Dir() [英] Checking if a path isDir()

查看:94
本文介绍了检查路径是否为Dir()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道检查特定路径是否是
目录的方法吗?如果我必须走下使用_findfirst和

_findnext(特定于Windows)的路线,那就这样吧。但是,我不认为它应该很难检查。


我最初的想法是检查路径是否可以打开使用

fstream,但如果路径是文件名,则可能会产生错误结果,并且

无法打开文件。我正在使用boost,并且看不到使用这个的任何方式

,或者我很确定它会实现

因为提升太棒了! br />

任何建议都会受到赞赏。


Daz

Would anyone know of a way to check whether or not a particular path is
a directory? If I have to go down the route of using _findfirst and
_findnext (windows specific), then so be it. However, I don''t think it
should be that difficult to check.

My original idea was to check to see if the path can be opened with
fstream, but this can give false results if the path is a filename, and
the file cannot be opened. I am using boost, and can''t see any way of
using this, or though I am pretty certain it would have been
implemented as boost is fantastic!

Any suggestions would be appreciated.

Daz

推荐答案

Daz写道:
Daz wrote:
有人知道检查特定路径是否是目录的方法吗?
Would anyone know of a way to check whether or not a particular path is
a directory?




很可能有人会知道这一点。但是,

标准C ++是不可能的,它不提供任何目录处理功能。



It''s likely that someone would know that. However, it is not possible in
standard C++, which doesn''t offer any directory handling functionality.


Daz写道:
有人知道检查特定路径
是否是目录的方法吗?


是的,新闻组中有人专门为您的操作系统编程。

" Directory"是一个C ++ _language_的概念(截至目前,无论如何)。

原因相对简单:C ++存在于某些平台上,而b / b
没有目录并且需要一个


如果你能用语言本身来告诉我们什么使你的

" path"一个目录,IOW,算法,我们可以帮助你用C ++表达它b / b
。如果该算法不能用C ++术语_only _,

写下来,或者如果你没有它,我们无法帮助你。

如果我不得不下去使用_findfirst和
_findnext(特定于Windows)的路线,那就这样吧。但是,我不认为它应该很难检查。


你认为它可能与Mac OS不同,比如VMS吗?

如果我能告诉你怎么做的话Mac OS,它会有所帮助吗?

我最初的想法是检查是否可以使用
fstream打开路径,但如果路径是文件名,则会产生错误结果,
和文件无法打开。我正在使用boost,并且看不到任何使用它的方式,或者虽然我很确定它会被实现,因为提升太棒了!
Would anyone know of a way to check whether or not a particular path
is a directory?
Yes, somebody in the newsgroup dedicated to programming your OS would.
"Directory" is a concept foreign to C++ _language_ (as of now, anyway).
The reason is relatively simple: C++ exists on some platforms that do
not have "directory" and requiring a

If you can tell us in the terms of the language itself what makes your
"path" a "directory", IOW, the algorithm, we can help you expressing it
in C++. If that algorithm cannot be written down in C++ terms _only_,
or if you just don''t have it, we cannot help you.
If I have to go down the route of using _findfirst and
_findnext (windows specific), then so be it. However, I don''t think it
should be that difficult to check.
Do you think it might be different on, say, a Mac OS versus, say, VMS?
If I can tell you how to do it on Mac OS, is it going to help?
My original idea was to check to see if the path can be opened with
fstream, but this can give false results if the path is a filename,
and the file cannot be opened. I am using boost, and can''t see any
way of using this, or though I am pretty certain it would have been
implemented as boost is fantastic!




Boost有自己的论坛,AFAIK。你应该问那里。


V

-

请在邮寄回复时从我的地址删除资金



Boost has its own discussion forums, AFAIK. You should ask there.

V
--
Please remove capital As from my address when replying by mail


我确实会在激励讨论论坛上询问,并且还会查看

创建一个便携式函数(如果它甚至可能),那我可以使用

并且可以在这个困境中帮助其他人。我认为我需要回答的问题是文件名与

目录之间的区别是什么?。我相信你只能对一个目录做一些事情,

你不能对文件和副文做。


V你说:
I will indeed ask in the boost discussion forum, and also look into
creating a portable function (if it''s even possible), that I can use
and may help others in this dilema. I think the question I need to
answer, is ''what''s the difference between a filename, and a
directory?''. I am sure there are things you can only do to a directory,
that you can''t do to a file and vice-verse.

V, you said:
是的,新闻组中有人专门为你的操作系统编程。
目录是一个C ++ _language_的概念(现在,无论如何)。
原因相对简单:C ++存在于某些平台上,而这些平台没有目录。并且需要一个
Yes, somebody in the newsgroup dedicated to programming your OS would.
"Directory" is a concept foreign to C++ _language_ (as of now, anyway).
The reason is relatively simple: C++ exists on some platforms that do
not have "directory" and requiring a



但我似乎看不到任何东西。


感谢输入的人!



but I can''t seem to see anything after it.

Thanks for the input guys!


这篇关于检查路径是否为Dir()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆