为什么C不了解目录? [英] WHY doesn't C know anything about directories?

查看:82
本文介绍了为什么C不了解目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于目录操作存在一系列问题,所有

已经回答没有便携式方法。


这提出了一个完全合理的问题,为什么,在这个时代,

C标准是否没有抽象和可移植的方法来处理目录?
这似乎不是一个特别困难的问题。例如,这个


int show_current_directory(struct DIRSTRUCT * current_directory);


可以返回如下状态值:


VALID_DIRECTORY

成功,结构填写

PLATFORM_HAS_NO_DIRECTORIES

不言而喻,你会看到什么一个嵌入式控制器,用于

实例。

CURRENT_DIRECTORY_DOES_NOT_EXIST

喜欢在cd / newdirectory之后,当

目录尚未创建。结构

已填写。该结构中的某些位表示

该目录实际上并不存在。

ERROR

不言而喻


DIRSTRUCT的组织可能与平台有关,所以

长作为关键操作(导航,创建目录,删除
目录,比较目录结构[我在这个目录中吗?])

完全支持这种类型的函数。


所以什么是真正的独家新闻。为什么不标准支持

便携式目录操作????


谢谢,


David Mathog

There have been a series of questions about directory operations, all of
which have been answered with "there is no portable way to do this".

This raises the perfectly reasonable question, why, in this day and age,
does the C standard have no abstract and portable method for
dealing with directories? It doesn''t seem like a particularly
difficult problem. For instance, this

int show_current_directory(struct DIRSTRUCT *current_directory);

could return status values like these:

VALID_DIRECTORY
success, and the structure is filled in
PLATFORM_HAS_NO_DIRECTORIES
self evident, what you''d see on an embedded controller, for
instance.
CURRENT_DIRECTORY_DOES_NOT_EXIST
like after "cd /newdirectory", when
the directory has not been created yet. Structure
is filled in. Some bit in that structure indicates
that the directory doesn''t actually exist.
ERROR
self evident

The organization of DIRSTRUCT could be platform dependent, so
long as key operations (navigation, create directory, delete
directory, compare directory structures [am I in this directory?]) are
fully supported by functions operating on this type.

So, what''s the real scoop. Why doesn''t the standard support
portable directory operations????

Thanks,

David Mathog

推荐答案

David Mathog< ma **** @ caltech.eduwrites:
David Mathog <ma****@caltech.eduwrites:

这提出了一个完全合理的问题,为什么,在这个时代,

C标准是否没有抽象和可移植的方法来处理目录?

This raises the perfectly reasonable question, why, in this day and age,
does the C standard have no abstract and portable method for
dealing with directories?



可能是因为基于C的标准提供了完美的目录API

,例如SUSv3及其前身。

没有必要将这些标准集成到C.

-

Ben Pfaff
http://benpfaff.org


在文章< f4 ********** @ naig.caltech.edu> ;,,David Mathog

< ma **** @ caltech.eduwrites
In article <f4**********@naig.caltech.edu>, David Mathog
<ma****@caltech.eduwrites

>有一系列关于目录操作的问题,所有这些问题都已经回答为没有可移植的方法来执行此操作。

这就提出了一个完全合理的问题,为什么在这个时代,为什么C标准没有抽象和可移植的方法来处理目录?这似乎不是一个特别困难的问题。
>There have been a series of questions about directory operations, all
of which have been answered with "there is no portable way to do this".

This raises the perfectly reasonable question, why, in this day and age,
does the C standard have no abstract and portable method for
dealing with directories? It doesn''t seem like a particularly
difficult problem.



因为并非所有文件系统都相同。

有许多变种已经到位。

任何新的系统都会破坏其中的许多系统


-

\ / \ / \ / \ / \ / \ / \\ \\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \

\ / \ / \ / \ / \ Chris Hills Staffs England / \ / \ / \ / \ /

/ \ / \ / ch***@phaedsys.org www.phaedsys.org \ / \ / \

\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \\ \\ / \ / \ / \ / \ / \ /

Because not all file systems are the same.
There are many variants about and already in place.
Any new system would break many of them

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/


Ben Pfaff写道:
Ben Pfaff wrote:

Da vid Mathog< ma **** @ caltech.eduwrites:
David Mathog <ma****@caltech.eduwrites:

>这提出了一个完全合理的问题,为什么,在这个时代,
C标准没有抽象和可移植的方法来处理目录吗?
>This raises the perfectly reasonable question, why, in this day and age,
does the C standard have no abstract and portable method for
dealing with directories?



可能因为


Probably because



(剪辑)


其实我希望参与

决定的其中一方可以告诉我们。我们都可以猜,但我想知道

的实际原因是什么。


谢谢,


David Mathog

(snip)

Actually I was hoping one of the parties who was actually in on the
decision could tell us. We can all guess but I''d like to know what the
actual reasons were.

Thanks,

David Mathog


这篇关于为什么C不了解目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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