亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? apr-tutorial-5.html

?? 跨平臺windowsunixlinux的c語言編程解決方案
?? HTML
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21"> <TITLE>libapr(apache portable runtime) programming tutorial: file handling</TITLE> <LINK HREF="apr-tutorial-6.html" REL=next> <LINK HREF="apr-tutorial-4.html" REL=previous> <LINK HREF="apr-tutorial.html#toc5" REL=contents></HEAD><BODY><A HREF="apr-tutorial-6.html">Next</A><A HREF="apr-tutorial-4.html">Previous</A><A HREF="apr-tutorial.html#toc5">Contents</A><HR><H2><A NAME="s5">5.</A> <A HREF="apr-tutorial.html#toc5">file handling</A></H2><P>When we handle files, we have to call apr_file_open() at first. Here is the prototype declaration.</P><P>/* excerpted from apr_file_io.h */<BLOCKQUOTE><CODE><PRE>APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname,                                        apr_int32_t flag, apr_fileperms_t perm,                                        apr_pool_t *pool);</PRE></CODE></BLOCKQUOTE></P><P>The first argument type is apr_file_t**, which is result argument. Namely, you can create an apr_file_t object by calling apr_file_open(). The second argument is file name path. The third argument is a bit-wised flag. The bit-flags are defined in apr_file_io.h. The fourth argument is file access permission, which has effects on a newly created file. The value is bit-wised flag. The bit-flags are defined in apr_file_info.h. For example, if you want to create a file that has an access permission 0600, i.e. read-write access only by the file owner, you have to specify APR_UREAD|APR_UWRITE. In usual cases, you can use APR_OS_DEFAULT as file permission. The fifth final argument is a memory pool to use. Needless to say, you need to create the memory pool by apr_pool_create().</P><P>After we open file, we can handle file by other APIs. We can find them in apr_file_io.h. The basic APIs are apr_file_read() and apr_file_write(). As you expect, apr_file_read() allows us to read something from file, and apr_file_write() allows us to write something to file. Here is the prototype declarations,</P><P>/* excerpted from apr_file_io.h */<BLOCKQUOTE><CODE><PRE>APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf,                                        apr_size_t *nbytes);APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf,                                         apr_size_t *nbytes);</PRE></CODE></BLOCKQUOTE></P><P>The third argument of both functions is value-result argument. It means, by which, we specify the input value's length on entry and get the output result's length on exit. In particular, apr_file_read() returns the length of read bytes and apr_file_write() returns the length of written bytes. Here is a sample code.</P><P><BLOCKQUOTE><CODE><PRE>/* pseudo code about apr_file_write() */strcpy(outbuf, "123456789");apr_size_t outlen = strlen(outbuf);rv = apr_file_write(fp, outbuf, &amp;outlen);printf("apr_file_write() rv = %d, nbytes = %d\n", rv, outlen);</PRE></CODE></BLOCKQUOTE></P><P>In this case, before calling apr_file_write(), 'outlen' variable's value is 9. Passing in &amp;outlen to apr_file_write() tells the API the writable length is 9. After returning from apr_file_write(), 'outlen' variable's value becomes actual written length. Usually, it is 9 if the file is a local file. Theoretically, it could become a smaller value (e.g. by disk full).</P><P>We have to call apr_file_close() to close the file. Rather than that, we can implicitly close the file by destroying the memory pool that is passed to apr_file_open(). I prefer explicit closing to such an implicit way. It's just my opinion.</P><P><EM>REMARK</EM>: There are some source code compatibility issues among libapr versions. The third argument of apr_file_open() has APR_FOPEN_ prefix after libapr-1.1.0, althouth it formerly didn't. We should use APR_FOPEN_CREATE instead of APR_CREATE. Please see apr_file_io.h of your using version.Similarly, the fourth argument of apr_file_open() has APR_FPROT_ prefixes after libapr-1.1.0.</P><P><EM>REMARK</EM>: There is a portability issue about file path separator. Unix(POSIX) uses slash('/'), and MS-Windows uses backslash('\') as separator. If you write an application program for both Unix and MS-Windows, I recommend you to canonicalize file pathes to use slash('/') as separators, because MS-Windows accepts it.</P><P><EM>REMARK</EM>: Be careful about apr_file_gets() usage. Calling apr_file_gets() without APR_BUFFERED severely hits performance. This is because that apr_file_gets() internally calls apr_file_read() per one byte. Remember you must open file with APR_BUFFERED flag when you use apr_file_gets(). </P><P>I recommend you to specify APR_BUFFERED flag except the following cases:<UL><LI>When you mmap the file (it causes an error to mmap APR_BUFFERED file)</LI><LI>No read/write (e.g. a file only for lock purpose)</LI><LI>You are sure that you reads/writes with a buffer big enough</LI></UL></P><P><EM>REMARK</EM>: While you open file with APR_BUFFERED flag and if you call apr_file_trunc() for the file, you must call apr_file_flush() before apr_file_trunc(). Otherwise, the file becomes broken.</P><P><EM>REMARK</EM>: When you open file with APR_BUFFERED flag and the file is shared by multiple threads, APR_XTHREAD flag is also required for the file. Unfortunately, APR_XTHREAD flag on Windows has a side effect. My experiences tell me not to use APR_XTHREAD flag on Windows.</P><P>We can get file information such as size, timestamp, owner, access permission, and so on. Such the information are in apr_finfo_t structure, which we find in apr_file_info.h. There are two related APIs as follows:</P><P>/* excerpted from apr_file_io.h */<BLOCKQUOTE><CODE><PRE>APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, apr_file_t *thefile);/* excerpted from apr_file_info.h */APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, apr_int32_t wanted, apr_pool_t *pool);</PRE></CODE></BLOCKQUOTE></P><P>apr_file_info_get() requires apr_file_t object, and apr_stat() requires file name. If we have already opened file and have apr_file_t object, it is better to use apr_file_info_get(). Otherwise, we have to call apr_stat(). Unlike other many types, apr_finfo_t is complete type. Rather than calling API to create object, we have to allocate the apr_finfo_t memory explicitly. Typically, it's allocated in local stack, because what we want to know might be some of the attributes such as file size or timestamp. Note that some memories, e.g. apr_finfo_t::fname, are allocated in the memory pool. This would cause a serious bug. Be careful.Please take a look at <A HREF="../sample/finfo-sample.c">finfo-sample.c</A> about the usage. </P><P>There are some file handling APIs that works based on file names. For example, apr_file_remove() and apr_file_copy(). You can find them in apr_file_io.h and apr_file_info.h.</P><P><EM>REMARK</EM>: Some APIs have 'wanted' argument that we specify bit-wised flag to get file attributes. The APIs are apr_dir_read(), apr_stat(), apr_lstat(), and apr_file_info_get(). Note that the value of 'wanted' argument could be beyond the OS file system support. and in such a case, the API returns APR_INCOMPLETE.</P><HR><A HREF="apr-tutorial-6.html">Next</A><A HREF="apr-tutorial-4.html">Previous</A><A HREF="apr-tutorial.html#toc5">Contents</A></BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品在线免费播放| 久久综合九色综合欧美亚洲| 精品理论电影在线观看| 午夜欧美大尺度福利影院在线看| av午夜一区麻豆| 国产日韩在线不卡| 国产在线不卡视频| 久久影视一区二区| 亚洲激情一二三区| 亚洲午夜免费福利视频| 国产麻豆精品在线| 中国色在线观看另类| 高清国产一区二区| 国产精品你懂的在线欣赏| 99久久综合99久久综合网站| 欧美极品另类videosde| www.av亚洲| 亚洲mv在线观看| 欧美一区二区在线免费播放| 一区二区免费在线| 精品福利在线导航| 国产1区2区3区精品美女| 67194成人在线观看| 狠狠色丁香久久婷婷综| 国产午夜精品一区二区三区视频 | 九九九精品视频| 欧美精彩视频一区二区三区| 成人精品高清在线| av亚洲精华国产精华| 精品久久久久久久久久久久久久久| 国产在线精品不卡| 国产精品丝袜一区| 极品瑜伽女神91| 亚洲精品视频在线| 69av一区二区三区| 亚洲综合区在线| 精品国产伦一区二区三区免费 | 国产人妖乱国产精品人妖| 粉嫩aⅴ一区二区三区四区五区| 亚洲国产日韩a在线播放性色| 3751色影院一区二区三区| 国产一区二区三区综合| 亚洲大片一区二区三区| 国产无遮挡一区二区三区毛片日本| 成人国产精品免费网站| 麻豆一区二区三区| 亚洲黄色在线视频| 欧美va亚洲va在线观看蝴蝶网| 欧美影院一区二区三区| 久99久精品视频免费观看| 中文字幕乱码日本亚洲一区二区| 8x8x8国产精品| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 成人国产精品视频| 日本欧美韩国一区三区| 17c精品麻豆一区二区免费| 日韩视频国产视频| 欧洲日韩一区二区三区| 国产精品系列在线播放| 美国精品在线观看| 亚洲成人免费看| 国产欧美1区2区3区| 日韩免费观看高清完整版在线观看| av在线综合网| 国产精品一区二区三区四区 | 中文字幕av资源一区| 日韩欧美国产精品一区| 91精品婷婷国产综合久久性色| 色综合一区二区三区| 日韩vs国产vs欧美| 日精品一区二区| 亚洲电影你懂得| 亚洲女子a中天字幕| 国产亚洲精品精华液| 日韩一区二区在线看片| 7777精品久久久大香线蕉| 91蝌蚪porny| 99re热这里只有精品视频| 99视频一区二区| 成人app软件下载大全免费| 国产综合色在线| 成人18精品视频| 国产成都精品91一区二区三| 肉色丝袜一区二区| 蜜桃久久久久久| 免费人成网站在线观看欧美高清| 免费人成网站在线观看欧美高清| 视频一区视频二区中文字幕| 午夜免费久久看| 毛片av一区二区| 国内精品国产成人| 国产精品中文字幕日韩精品| 粉嫩av一区二区三区在线播放 | 午夜久久电影网| 国产精品少妇自拍| 亚洲人精品午夜| 一区二区三区在线免费观看| 亚洲高清视频中文字幕| 亚洲成人黄色影院| 青青青伊人色综合久久| 国产在线精品免费av| 成人小视频在线| 96av麻豆蜜桃一区二区| 精品视频资源站| 91精选在线观看| 欧美国产精品劲爆| 自拍av一区二区三区| 一区二区三区在线视频免费| 日韩av在线免费观看不卡| 久久99久久久久久久久久久| 国产美女精品在线| 日本国产一区二区| 欧美日韩国产一级片| 精品视频1区2区| 日韩一区二区中文字幕| 欧美激情一二三区| 亚洲国产精品综合小说图片区| 日本欧美韩国一区三区| 国产不卡在线播放| 欧美日本在线播放| 久久先锋资源网| 亚洲国产欧美日韩另类综合| 久久69国产一区二区蜜臀| 成人高清免费观看| 日韩亚洲欧美在线| 久久精品免视看| 中文字幕一区在线观看视频| 婷婷成人激情在线网| 国产精品1024| 欧美一三区三区四区免费在线看 | 2020日本不卡一区二区视频| 亚洲天天做日日做天天谢日日欢 | 日韩久久久久久| 亚洲欧美色图小说| 国产不卡视频在线播放| 欧美女孩性生活视频| 欧美激情一区二区三区四区| 老司机精品视频导航| 91视频免费看| 久久人人爽爽爽人久久久| 丝袜亚洲精品中文字幕一区| 大胆亚洲人体视频| 欧美日韩视频在线第一区| 中文字幕亚洲精品在线观看| 蜜臀久久99精品久久久久宅男| 粉嫩aⅴ一区二区三区四区| 日韩欧美第一区| 亚洲黄色免费电影| 精品中文字幕一区二区| 91精品国产综合久久精品图片| 国产精品狼人久久影院观看方式| 亚洲永久免费av| 高清在线观看日韩| 日韩精品综合一本久道在线视频| 欧美国产精品v| 精品一二线国产| 欧美日韩国产经典色站一区二区三区 | 色视频欧美一区二区三区| 26uuu色噜噜精品一区二区| 麻豆freexxxx性91精品| 欧美日韩国产乱码电影| 一区二区三区四区在线免费观看| 成人av资源站| 国产视频一区二区在线| 日日噜噜夜夜狠狠视频欧美人| 7777精品久久久大香线蕉| 亚洲午夜精品网| 欧美日韩高清影院| 亚洲无人区一区| 91视频www| 亚洲久草在线视频| 成人av在线电影| 国产精品日日摸夜夜摸av| 成人网在线免费视频| 国产日韩欧美一区二区三区乱码| 毛片av一区二区三区| 久久蜜桃av一区精品变态类天堂| 日本在线播放一区二区三区| 成a人片国产精品| 樱花草国产18久久久久| 94-欧美-setu| 亚洲va欧美va天堂v国产综合| 精品视频在线看| 五月婷婷久久丁香| 欧美一区二区三区四区五区| 首页国产欧美日韩丝袜| 欧美视频中文一区二区三区在线观看| 亚洲你懂的在线视频| 91免费在线播放| 日日骚欧美日韩| 欧美videos大乳护士334| 丝袜国产日韩另类美女| 精品久久一区二区| 国产91丝袜在线18| 国产精品网曝门| 色哟哟日韩精品| 亚洲成人综合网站| 久久精品一区蜜桃臀影院| 成人性生交大片免费| 一区二区三区 在线观看视频|