Linux C 创建目录函数mkdir相关

I.Linux C 创建目录函数mkdir的mode设置问题

函数原型:

#include <sys/stat.h>

int mkdir(const char *path, mode_t mode);

参数:

path是目录名

mode是目录权限

返回值:

返回0 表示成功, 返回 -1表示错误,并且会设置errno值。

mode模式位:

mode 表示新目录的权限,可以取以下值:

S_IRUSR
S_IREAD

S_IWUSR
S_IWRITE
S_IXUSR
S_IEXEC
S_IRWXU
This is equivalent to (S_IRUSR | S_IWUSR | S_IXUSR).
S_IRGRP
Read permission bit for the group owner of the file. Usually 040.
S_IWGRP
Write permission bit for the group owner of the file. Usually 020.
S_IXGRP
Execute or search permission bit for the group owner of the file. Usually 010.
S_IRWXG
This is equivalent to (S_IRGRP | S_IWGRP | S_IXGRP).
S_IROTH
Read permission bit for other users. Usually 04.
S_IWOTH
Write permission bit for other users. Usually 02.
S_IXOTH
Execute or search permission bit for other users. Usually 01.
S_IRWXO
This is equivalent to (S_IROTH | S_IWOTH | S_IXOTH).
S_ISUID
This is the set-user-ID on execute bit, usually 04000. See How Change Persona.
S_ISGID
This is the set-group-ID on execute bit, usually 02000. See How Change Persona.
S_ISVTX
This is the sticky bit, usually 01000.

例子:

#include <sys/types.h> #include <sys/stat.h>
int status;

status = mkdir("/home/newdir", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);

这样就创建了一个newdir目录,权限通过ls -al 查看为

drwxr-xr-x

跟用linux命令mkdir创建的目录权限位一致。


II. linux下C语言创建多级目录

int CreateDir(const char *sPathName)
{
char DirName[256];
strcpy(DirName, sPathName);
int i,len = strlen(DirName);
if(DirName[len-1]!='/')
strcat(DirName, "/");

len = strlen(DirName);

for(i=1; i<len; i++)
{
if(DirName[i]=='/')
{
DirName[i] = 0;
if( access(DirName, NULL)!=0 )
{
if(mkdir(DirName, 0755)==-1)
{
perror("mkdir error");
return -1;
}
}
DirName[i] = '/';
}
}

return 0;
}

III.linux c 编程:创建一个线程,监视某个目录,一旦目录里出现新的文件,就将文件转移到指定的目录里去。
/*
头文件
*/
#define SRCPATH "srcpath/"
#define DSTPATH "dstpath/"

int movefile()
{
DIR *dir;
struct dirent *dt;
FILE *fp1,*fp2;
char filename1[256],filename2[256];
char buf[1024];
int readsize,writesize;

if((dir = opendir(SRCPATH)) == NULL)
{
printf("opendir %s error\n",SRCPATH);
return -1;
}
memset(filename1,0,sizeof(filename1));
strcpy(filename1,SRCPATH);
memset(filename2,0,sizeof(filename2));
strcpy(filename2,DSTPATH);
while(1)
{
while((dt = readdir(dir)) != NULL)
{
if(strcmp(dt->d_name,".")==0||strcmp(dt->d_name,"..")==0)
{
continue;
}
//如果这个目录里 还有目录,可以在这加判断
//这里假设初始为空目录
strcat(filename1,dt->d_name);
strcat(filename2,dt->d_name);
//如果进程资源较少可以直接用linux系统命令

fp1 = fopen(filename1,"rb");
if(fp1==NULL)
{
printf("open %s failed /n",filename1);
return -1;
}

fp2 = fopen(filename2,"wb");
if(fp2==NULL)
{
printf("open %s failed /n",filename2);
fclose(fp1);
return -1;
}

while((readsize = fread(buf,sizeof(buf),1,fp1))>0)
{
//total += readsize;
memset(buf,0,sizeof(buf));
writesize = fwrite(buf,sizeof(buf),1,fp2);
if(writesize!==readsize)
{
printf("write error");
return -2;
fclose(fp1);
fclose(fp2);
}
}
fclose(fp1);
fclose(fp2);
rmdir(filename2);
}
}
}

int main(int argc,char **argv)
{
pthread_t id1;
int ret;
ret = pthread_create(&id1, NULL, (void*)movefile, NULL);
return ret;
}
Linux命令·mkdir mkdir 阅读详情

相关推荐

C语言目录操作详解

每调用一次 readdir 函数会返回一个struct dirent的地址,存放了本次读取到的内容,它的原理与fgets函数读取文件相同。getcwd函数把当前工作目录存入buf中,如果目录名超出了参数size长度,函数返回NULL,如果成功,返回buf。文件是存放在目录中的,在处理文件之前,必须先知道目录中有哪些文件,所以要获取目录中的文件列表。文件存放在某目录中,该目录下还会有多级子目录。列出该目录及其子目录下全部的文件名。命令来创建/删除目录,C程序中用。来显示当前的工作目录。函数来创建/删除目录。

喜欢编程,将自己会的知识分享给大家 3691

Linux C/C++源码实现常见命令mkdir

Linux系统是由文件和目录组成的。当我们使用Linux系统时,经常会从中创建目录来保存文件等等,这时会使用Linux自带 mkdir 的命令,用于在操作系统中创建目录或文件夹。在本文中,我们将讨论如何使用带有各种命令行选项的 mkdir 命令以及代码实现。 mkdir命令代码实现 在 Linux 中,虽然 rm 命令允许您删除目录,但首先是 mkdir 命令允许您创建目录。下面我们实现mkdir命令: #include <stdio.h> #include <sys/types.h&gt

chen1415886044的博客 5939

【vLLM-性能洞察】基于Ascend Profiler的端到端推理瓶颈定位与优化实践

本文详细介绍了如何利用Ascend Profiler对vLLM-Ascend大模型推理服务进行端到端的性能瓶颈定位与优化。通过实战案例,阐述了从数据采集、可视化分析到诊断低效算子、内存管理、计算通信重叠及框架调度等常见瓶颈的全过程,为基于昇腾NPU的AI推理性能调优提供了系统性的方法论和实用工具指南。

cc789的博客 548

c/c++ 创建全局目录(linux 系统)

环境 系统:linux 系统函数调用 使用的是<sys/stat.h> 里面的 mkdir() 函数。 mkdri缺点是,如果输入为多级目录且存在上一级目录不存在的情况,则创建目录失败。举例:创建一个全局路径为 /A/B/C/D/ 的目录,如果A、B、C中有一层目录不存在,则创建此路径失败。 策略 根据mkdir函数的特点,我们的策略是将全局路径里的各级目录拆分开来,一层一层的创建。 代码 通过mkdir创建全局路径的函数是我在分析log4cplus源码时候学习的,源码里面有很多logcplu

qq_39513781的博客 3513

MT4量化交易入门:手把手教你用MQL4编写第一个外汇EA(含完整代码)

本文详细介绍了如何使用MQL4在MT4平台上编写第一个外汇EA,涵盖从开发环境配置到均线交叉策略实现的完整流程。通过手把手教学和完整代码示例,帮助量化交易新手快速掌握外汇自动化交易的核心技术,实现高效的MT4量化交易系统。

mmm90的博客 539

Coppelia Sim (v-REP)仿真 机器人3D相机手眼标定与实时视觉追踪 (一)

先把这连个都添加到场景中,然后把kinect的depth相机拖到vision sensor中,把kinect的script也拖到vision sensor中,同时要注意修改深度相机的坐标,及修改script,删掉/rgb部分。由于需要导入到仿真场景中PDF文件不能直接导入,所以需要生成图下文件,使用windows自带的画图工具,生成以厘米为单位的图像格式,大小和标定板的设置大小一直。可以生成需要用的标定板的文件,设置标定板的大小,棋盘格的大小,等相关的参数,之后可以保存PDF文件。设置plane的大小。

hong3731的专栏 1756

Linux下用C语言使用函数创建一个目录、多级目录以及删除目录(mkdir,access,rmdir函数)

参数含义:需要删除目录的对应路径名,并且该目录必须是一个空目录,也就是该目录下只有.和..这两个目录。pathname指定的路径名不能是软链接文件,即使该链接文件指向了一个空目录。若目录创建成功,则返回0;否则返回-1,并将错误记录到全局变量errno中。返回值:成功返回0;并会设置errno.

qq_61988957的博客 6779

Vivado项目开发新思路:用VSCode写代码,用Vivado管理IP核与综合(Windows/Mac环境通用指南)

本文介绍了如何结合Vivado和VSCode的优势,打造高效的FPGA设计工作流。通过配置VSCode的Verilog插件和Vivado环境集成,开发者可以在VSCode中编写代码,同时利用Vivado管理IP核与综合,显著提升开发效率和团队协作体验。

weixin_42545503的博客 343

linux下mkdir头文件_Linux C 创建目录函数mkdir相关【转】

————————————————————————————————————————————————I.LinuxC 创建目录函数mkdir的mode设置问题函数原型:#include int mkdir(const char *path, mode_t mode);参数:path是目录名mode是目录权限返回值:返回0 表示成功, 返回 -1表示错误,并且会设置errno值。mode模式位:mod...

weixin_29547681的博客 484

钉钉开发(三)——Java推送钉钉待办任务

之前一篇博文中,讲解了如何推送钉钉群消息,感兴趣的可以点击查看。 钉钉开发(一)——Java给钉钉群推送消息

Monten_Cristo的博客 6418

【时间序列预测算法】——Holt-Winters算法介绍及代码实现

背景 一阶二阶三阶指数平滑方法拟合效果均较好,通过结合数据自然属性,数据自身、趋势变化、季节性,提出了这三个角度的衡量量,可以说,理解起来更自然、更亲切。 公式 一阶: sts_tst​是t时刻对xtx_txt​的估计值,这里只有一个参数α,是数据本身的平滑属性的体现。 二阶: 引入了时间趋势变量btb_tbt​,优化了一下一阶的公式。同时还可以预测t+m时刻的值: 三阶: 又引入了季节性周期描述变量ctc_tct​,优化了一下二阶的公式。同时还可以预测t+m时刻的值: NOTE:ct

BlackValley的博客 1万+

linux给生成的文件加表头,Linux C 创建目录函数mkdir相关

————————————————————————————————————————————————I.Linux C 创建目录函数mkdir的mode设置问题 函数原型: #include int mkdir(const char *path, mode_t mode); 参数: path是目录名 mode是目录权限 返回值: 返回0 表示成功, 返回 -1表示错误,并且会设置er...

weixin_36145482的博客 851

Python编程基础05:运算符与表达式

文章目录一、算术运算符1、分类说明表2、注意事项3、案例演示任务1、计算成绩差与平均成绩课堂练习:编程处理带余除法。任务2、打印购物小票 运算符就是专门用于告诉程序执行特定运算或逻辑操作的符号。表达式是指由常量、变量和运算符组成的一个算式。编写程序对数据进行处理,其实处理就是对数据实施各种各样的运算,搞懂运算符与表达式是我们编写程序的基础性工作,本次讲课笔记通过案例讲解各种运算符的用法以及正确书写Python表达式的注意事项。 一、算术运算符 Python中的算术运算符就是用来处理四则运算的符号,也是

howard2005的专栏 3128

Linux C 创建目录函数mkdir相关【转】

转自:http://blog.csdn.net/fallenink/article/details/8480483 原文地址:http://sharp2wing.iteye.com/blog/1280802 ———————————————————————————————————————————————— I.LinuxC 创建目录函数mkdir的mod...

weixin_34370347的博客 220

大学计算 - NumPy库的矩阵运算 实训答案

本文介绍了三个NumPy矩阵操作的实验练习。第一关练习ndarray类型操作,包括矩阵构造、元素平方和计算、矩阵乘积运算和逆矩阵行列式计算;第二关针对matrix类型,涉及绝对值最大值获取、特定矩阵乘积运算和转置矩阵特征值计算;第三关实现Moore-Penrose伪逆矩阵计算,并与NumPy内置pinv函数结果比较误差。实验涵盖了NumPy核心矩阵操作,展示了从基础运算到高级矩阵分解的应用,帮助掌握科学计算中的矩阵处理技巧。

2403_89314916的博客 317

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IBM Planning Analytics Assistant:自然语言驱动的智能分析解决方案

自然语言处理(NLP)技术正在重塑商业智能(BI)领域,通过语义理解实现业务需求与技术实现的解耦。IBM Planning Analytics Assistant基于watsonx Orchestrate平台,采用三层架构处理自然语言查询:语义理解层解析用户意图,模型映射层转换为底层查询,结果优化层智能呈现。该方案显著降低使用门槛,业务人员无需掌握MDX或SQL即可完成复杂分析,测试显示对'对比去年同期利润率变化'类查询准确率达92%。典型应用场景包括财务预算分析和供应链优化,某快消企业实施后库存周转率提升

weixin_34032621的博客 373

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

linux c语言创建目录 access strcat,Linux C 创建目录函数mkdir相关(转-清新居士)

I.Linux C 创建目录函数mkdir的mode设置问题函数原型:#include int mkdir(const char *path, mode_t mode);参数:path是目录名mode是目录权限返回值:返回0 表示成功, 返回 -1表示错误,并且会设置errno值。mode模式位:mode 表示新目录的权限,可以取以下值:S_IRUSRS_IREADS_IWUSRS_IWRITES...

weixin_32965939的博客 318

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Linux C 创建目录函数mkdir相关(转-清新居士)

I.Linux C 创建目录函数mkdir的mode设置问题 函数原型: #include <sys/stat.h> int mkdir(const char *path, mode_t mode); 参数: path是目录名 mode是目录权限 返回值: 返回0 表示成功, 返回 -1表示错误,并且会设置errno值。 mode模式位: mode 表示新目录的权限...

weixin_33753845的博客 90

[C] 创建目录_mkdir()函数

  在使用面函数的时候,容易出现找不到头文件,可以通过Linux下的find命令查找是否存在其他目录中(find/usr/include-name"io.h"),然后将其拷贝到“/usr/include/”目录下,一般需要root权限。 一、创建目录 共有两种方式,可以选择其中一种,推荐第二种,可以直接设置权限。 1.1 direct.h 头文件 int mkdir(const ch...

weixin_33693070的博客 829

Linux 高并发学习笔记 - Linux 目录操作函数

Linux 目录操作函数。chdir函数切换工作目录,getcwd函数查看工作目录,mkdir函数创建目录,rmdir函数与remove函数移除目录或文件,rename函数重命名或移动目录或文件。opendir函数,closedir函数,readdir函数,seekdir函数实现目录遍历。

凉皮大大的博客 319

linux系统目录操作接口

linux 中使用 DIR 结构体来描述一个已经打开的目录,至于结构体中有什么具体的内容,我们不需要关心,只需要知道 DIR 类型的指针可以表示一个已经打开的目录就可以了。读取 DIR 指向的目录中的文件项,通过返回值返回出文件信息,每一次调用 readdir都会让 DIR 指针指向该目录的下一个文件的位置。打开文件描述符为 fd 的目录,返回一个 DIR 类型指针,DIR 是用来描述打开目录信息的结构体。打开名为 name 的目录,返回一个 DIR 类型指针,DIR 是用来描述打开目录信息的结构体。

jiu_yue_ya的博客 537

linux C —— 文件操作函数

chmodint chmod(const char *path, mode_t mode) 将文件read的文件权限变成所有者有读写权限,其他用户只有读的权限。这和shell指令中的chmod有相同的功效。#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> /* for chmod */ #include <sys/types.

theArcticOcean 4712
上一篇: Linux下的C编程实战之文件系统编程
下一篇: FileInputStream/FileOutputStream的应用
sharp2wing
博客等级 码龄19年 5粉丝 89原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址