apr_file_open函式用法心得
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 | ||
) |
Open the specified file.
- Parameters:
-
newf The opened file descriptor. fname The full path to the file (using / on all systems) flag Or'ed value of: APR_READ open for reading APR_WRITE open for writing APR_CREATE create the file if not there APR_APPEND file ptr is set to end prior to all writes APR_TRUNCATE set length to zero if file exists APR_BINARY not a text file (This flag is ignored on UNIX because it has no meaning) APR_BUFFERED buffer the data. Default is non-buffered APR_EXCL return error if APR_CREATE and file exists APR_DELONCLOSE delete the file after closing. APR_XTHREAD Platform dependent tag to open the file for use across multiple threads APR_SHARELOCK Platform dependent support for higher level locked read/write access to support writes across process/machines APR_FILE_NOCLEANUP Do not register a cleanup with the pool passed in on the pool argument (see below). The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed. APR_SENDFILE_ENABLED Open with appropriate platform semantics for sendfile operations. Advisory only, apr_socket_sendfile does not check this flag.
perm Access permissions for file. pool The pool to use.
- Remarks:
- If perm is APR_OS_DEFAULT and the file is being created, appropriate default permissions will be used.
- By default, the returned file descriptor will not be inherited by child processes created byapr_proc_create(). This can be changed using apr_file_inherit_set().
- 如果你是服務端,客戶端請求傳送檔案,你寫在指定路徑下,此時在開啟檔案時需要注意,apr_file_open函式,第三個引數應該寫為
- APR_WRITE|APR_CREATE| APR_TRUNCATE,其中APR_TRUNCATE表示,如果檔案已經存在,則先將檔案清空,這樣就不會發生以下這種情況:
- 先發個大的檔案,再傳送個小檔案,此時新生成的檔案不會全部覆蓋以前的檔案,這就是BUG,故將引數設定成像上述所說的一樣!
- 當頻繁呼叫該函式,及需要在Pool上開闢空間的函式,應該使用區域性的 pool !!!
相關文章
- Translate函式用法函式
- abs函式用法函式
- ascii函式和substr函式的用法ASCII函式
- GetModuleFileName函式的用法函式
- SQL LEN()函式用法SQL函式
- SSD-函式用法函式
- createStyleSheet()函式的用法函式
- OVER(PARTITION BY)函式用法函式
- qsort函式的用法函式
- oracle table()函式用法Oracle函式
- COALESCE函式的用法。函式
- PHP 自定義函式用法及常用函式集合PHP函式
- C++ replace() 函式用法C++函式
- Python range() 函式用法Python函式
- Python排序函式用法Python排序函式
- Instr函式的用法函式
- 【Oracle的NVL函式用法】Oracle函式
- fcntl函式用法詳解函式
- fork()函式的基本用法函式
- eval()函式用法詳解函式
- replaceChild()函式用法介紹函式
- Oracle dump函式的用法Oracle函式
- PHP trim()函式 用法示例PHP函式
- openat()函式的用法示例函式
- instr、substr函式用法函式
- Oracle trunc()函式的用法Oracle函式
- Oracle 函式 Translate 的用法Oracle函式
- oracle的with函式用法示例Oracle函式
- C語言中函式printf()和函式scanf()的用法C語言函式
- 我的MYSQL學習心得(6) : 函式MySql函式
- C++回撥函式 用法C++函式
- C++ 函式 realloc 的用法C++函式
- C# List常用函式用法C#函式
- PostgreSQL>視窗函式的用法SQL函式
- string 函式的基本用法函式
- Excel函式的初級用法Excel函式
- js Date.now()函式用法JS函式
- sys_context函式用法Context函式