本文介绍了从文件中获取文件名*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嗨 我们正在为64位版本的lcc-win 重写libc,我们在FILE结构中添加了一个新字段: char * FileName; fopen()将保存文件名和访问者函数 将返回给定文件名*的文件名。 问题: 这个函数的最佳名称是什么? char * fname(FILE *); //小写,短,类似于其他 //文件功能 //明确名称但可能太长了? char * FileNameFromFileP(FILE *); 此功能可能出现什么问题?为什么不在C API中? 我们正在考虑扩展我们的文件函数来处理许多文件系统支持的文件属性。我们将有两个 指针指向扩展属性和一个用户指针。指针, 即一个指针,由用户设置并带有用户 定义的数据,我们不会触及。访问者/设置者函数 将允许用户设置/检索数据。 请注意,FILE结构现在是一个完全不透明的结构。 用户无法获得FILE的定义,但是 struct __FILE; typedef struct __FILE FILE; - jacob navia jacob at jacob point remcomp point fr logiciels / informatique http://www.cs.virginia.edu/~lcc-win32 解决方案 它应该为tempfile(),stdin,stdout,stderr返回什么? 因为FILE不需要是一个结构。 另外,为什么不把它作为一个宏写入所有大写字母?你要做的就是 从结构中返回一个元素... 我不明白最后两行... 如果文件被删除(remove()/ unlink())会发生什么,而它仍然是打开的(在POSIX中)是可能的,不确定C标准或Windowds 对此有何说法)? 在这种情况下,文件名将消失,不再存在。 我们正在考虑扩展我们的文件函数来处理许多文件系统支持的文件属性。我们将有两个 指针指向扩展属性和一个用户指针。指针, 即一个指针,由用户设置并带有用户 定义的数据,我们不会触及。访问者/设置者函数 将允许用户设置/检索数据。 请注意,FILE结构现在是一个完全不透明的结构。 用户无法获得FILE的定义,但是 struct __FILE; typedef struct __FILE FILE; 什么是文件名?插座或管道?由tmpnam()创建的文件 ?斯坦丁?如果所有的调用程序都打开了你打开的文件,那么你可以找到几个可能的名字 来查找文件系统有真正的象征性 链接?在具有备用数据流(ADS)的系统中, 可以是具有类似于符号链接的效果的程序,或者是用于循环安装的? - 罗马人相信每个男人都有他的天才,每个男人都有她的朱诺。 - Thomas Bulfinch HiWe are rewriting the libc for the 64 bit version of lcc-winand we have added a new field in the FILE structure:char *FileName;fopen() will save the file name and an accessor functionwill return the file name given a FILE *.Questions:What would be the best name for this function?char *fname(FILE *); // lower case, short, similar to other// file functions// clear name but maybe too long?char *FileNameFromFileP(FILE *);What problems could arise with this function? Why is not in the C API?We are considering extending our file functions to handlefile attributes that many file systems support. We will have twopointers that point to extended attributes and a "user" pointer,i.e. a pointer that would be set by the user and would carry userdefined data that we would not touch. An accessor/setter functionwould allow the user to set/retrieve data.Note that the FILE structure is now a completely opaque structure.No definition for FILE will be available to the user butstruct __FILE;typedef struct __FILE FILE;--jacob naviajacob at jacob point remcomp point frlogiciels/informatique http://www.cs.virginia.edu/~lcc-win32 解决方案What should it return for tempfile(), stdin, stdout, stderr?Because FILE needs not to be a struct.Also, why not just write it as a macro in all caps? All you do isreturn an element from the struct anyway...I don''t understand these last two lines...What happens if the file gets deleted (remove()/unlink()), while it is stillopen (in POSIX that is possible, not sure what the C Standard nor Windowdssays about this)?In that case the filename would have disappeared, no longer exist.What is the "file name" of a socket or pipe? Of a file createdby tmpnam() ? Of stdin? If all the calling program hands you isthe open file, then -which- of the several possible names for itare you going to find for the file, in a system which has true symboliclinks? In a system which has Alternate Data Streams (ADS) thatcan be programs that have effects similar to symbolic links orto loop-back mounts?--"The Romans believed that every man had his Genius, and everywoman her Juno." -- Thomas Bulfinch 这篇关于从文件中获取文件名*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!