⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch08-chdir.c

📁 linux编程精髓 源代码
💻 C
字号:
/* ch08-chdir.c --- demonstrate chdir() and fchdir().                    Error checking omitted for brevity */#include <stdio.h>#include <fcntl.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>int main(void){	int fd;	struct stat sbuf;	fd = open(".", O_RDONLY);	/* open directory for reading */	fstat(fd, & sbuf);		/* obtain info, need original permissions */	chdir("..");			/* `cd ..' */	fchmod(fd, 0);			/* zap permissions on original directory */	if (fchdir(fd) < 0)		/* try to `cd' back, should fail */		perror("fchdir back");	fchmod(fd, sbuf.st_mode & 07777);	/* restore original permissions */	close(fd);			/* all done */	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -