DJHartley / iphonedisk

Automatically exported from code.google.com/p/iphonedisk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fopen("/Volumes/iphonedisck/test","ab") is the same as fopen("/Volumes/iphonedisck/test","wb") in iphonedisck

GoogleCodeExporter opened this issue · comments

What steps will reproduce the problem?
1.FILE* fp = fopen("/Volumes/iphonedisck/test","ab");
2.fwrite("abc", 1, 4, fp);
3.fclose(fp);

What is the expected output? What do you see instead?
it will add "abc" at the end of the test file,but the text file's source remove 
and add "abc" at the begin of the test file

What version of the product are you using? On what operating system?
 Disk for iPhone 20100411.dmg, on mac 10.5.8 and 10.6.4

Please provide any additional information below.

Original issue reported on code.google.com by yaoyupi...@gmail.com on 26 Aug 2010 at 2:50

Investigating.  Thanks for the excellent bug report.

Original comment by allen.po...@gmail.com on 31 Aug 2010 at 2:17

  • Changed state: Accepted
I attempted to reproduce this and have not had luck yet.  I used the latest 
version from the source tree.

$ cat c.c 
#include <stdio.h>

int main(int argc, char* argv[]) {
  FILE* fp = fopen("/Volumes/ip/test", "ab");
  fwrite("abc", 1, 4, fp);
  fclose(fp);
  return 0;
}
$ gcc -Wall -Werror -o c c.c
$ echo zzzzzzzz > /Volumes/ip/test
$ od -x /Volumes/ip/test
0000000      7a7a    7a7a    7a7a    7a7a    000a                        
0000011
$ ./c 
$ od -x /Volumes/ip/test
0000000      7a7a    7a7a    7a7a    7a7a    610a    6362    0000        
0000015


Original comment by allen.po...@gmail.com on 10 Oct 2010 at 5:07

I tried on the released version as well and had similar results.  I'm not sure 
how to proceed.  Maybe you can run the same commands that I did and show me the 
results?

Original comment by allen.po...@gmail.com on 10 Oct 2010 at 5:12