In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Everything in Linux is a file!
This piece of content is mainly a variety of operations on Linux files: open, close, new, read, write, etc., C functions (not Shell commands!) As follows:
int open(const char *path,int oflags,mode_t mode)
[path: path/oflags: open mode (see Note 2)/mode: permission/return: handle, error: -1]
Note 1: If the file does not exist, create it.
Note 2: oflags are:
O_RDONLY: file read-only;(similar to "open as read-only" in excel to protect the file from being altered)
O_WRONLY: file write only;
O_RDWR: file readable and writable;
O_NOCTTY: If the path points to a terminal, the device is not used as the control terminal for this process (it can still be used if the path is a terminal console);
O_NDELAY: Non-blocking mode operation file
Note 3: A handle is actually a pointer to a file structure, like holding up a card in a crowd to say "I'm here, something's coming for me"
int close(int fd)
fd: Handle of an open file
int creat(const char *pathname,mode_t mode)
[path: path/mode: permission]
ssize_t read(int fd,void *buf,size_t len)
[fd: Handle of opened file/buf: Storage location of read data/len: Length of read data (bytes)/return: Actual number of bytes of read data, Error: -1]
ssize_t write(int fd,void *buf,size_t count)
[fd: Handle of opened file/buf: Data to be written/count: Length of data to be written (bytes)/return: Actual number of bytes of data written, Error: -1]
4 header files for file operations:
#include
#include
#include
#include
Where are the above header files at ×××? Type "man 2 open" under shell.
P.S. In order to better understand this chapter, it is recommended to review the relevant contents of Tan Haoqiang's C Language Programming (Fourth Edition), which has some conceptual things, fopen (), fclose (), etc.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.