admin管理员组文章数量:1415460
Every language I've done some form of file handling in has some form of read/write specification when interacting with a file, something like
open_file(file_name, read=true)
Is this typically implemented in the library? Or is there some simple operating system support that library devs can leverage?
I looked around the python file handling docs but I didn't see any clear specification of how read/write worked.
Every language I've done some form of file handling in has some form of read/write specification when interacting with a file, something like
open_file(file_name, read=true)
Is this typically implemented in the library? Or is there some simple operating system support that library devs can leverage?
I looked around the python file handling docs but I didn't see any clear specification of how read/write worked.
Share Improve this question asked Feb 21 at 2:57 user29573453user29573453 1 1- You should looking into read, write, and open syscalls. For instance, in Linux. – wxz Commented Feb 22 at 3:15
1 Answer
Reset to default 0In order to be portable, languages would usually not specify how things are implemented.
However, almost always file permissions they are implemented by the operating system. For example, most operating systems implement some subset of POSIX. A POSIX operating system allows you to open a file as follows:
int open(const char *path, int oflag, ... );
And the documentation of oflag includes:
Applications shall specify exactly one of the first three values (file access modes) below in the value of oflag:
O_RDONLY
Open for reading only.
O_WRONLY
Open for writing only.
O_RDWR
Open for reading and writing. The result is undefined if this flag is applied to a FIFO.
Language implementations simply translate calls such as open_file(file_name, read=true)
to the operating system's equivalent of open()
.
本文标签: operating systemtypical implementation of readwrite permissions in file reading codeStack Overflow
版权声明:本文标题:operating system - typical implementation of readwrite permissions in file reading code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745169570a2645891.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论