2013-12-18 100 views
-1

我想知道REDIS如何編寫二進制數據。 它打開的文件不是「b」模式。Redis如何將二進制數據寫入轉儲文件?

fp = fopen(tmpfile,"w") 

在這方面的任何幫助。

+0

你想達到什麼實際出這個? –

+0

我想知道爲什麼我用「vim」打開轉儲文件,並得到凌亂的代碼。它就像一個二進制文件,但不能用「wb」模式打開。 – lanyun

+0

它是一個二進制文件。它並不意味着在文本編輯器中打開。 –

回答

0

在LIUNX,FOPEN沒有B方式,請參閱fopen人DOC:

r  Open text file for reading. The stream is positioned at the beginning of the file. 

    r+  Open for reading and writing. The stream is positioned at the beginning of the file. 

    w  Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. 

    w+  Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. 

    a  Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file. 

    a+  Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, 
      but output is always appended to the end of the file.