Access functions in "Go" c

Source: Internet
Author: User

Http://blog.chinaunix.net/uid-22785134-id-360282.html

int access (const char *filename, int amode);
A amode parameter of 0 indicates the existence of the check file, if the file exists, returns 0, does not exist, returns-1.
This function can also check other file attributes:
06 Checking Read and Write permissions
04 Checking Read Permissions
02 Checking Write permissions
01 Checking Execution Permissions
00 checking the existence of files
And this even if the file does not have Read permission, you can also determine whether the file exists in the
There is a return of 0, there is no return-1

C function
Name of function: Access
Function: Determine access rights to a file
Usage: int access (const char *filename, int amode);

#include <stdio.h>#include<io.h>intFile_exists (Char*filename); intMainvoid) {printf ("Does notexist.fil exist:%s\n", File_exists ("Notexists.fil") ?"YES":"NO"); return 0; } intFile_exists (Char*filename) {     return(Access (filename,0) ==0); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.