Christian Biesinger wrote: > prodizy wrote: > > Which of the following is the best way to read and write files in an > > XPCOM component(using C++)? > > FileOutputStream or nsILocalFile::OpenNSPRFileDesc are the best way
Yeah, I did exactly the same as nsLocalFile::OpenAnsiFileDesc() was not working for me. > > 2. nsIFileInputStream & nsIFileOutputStream? - I want to avoid this as > > these interfaces are not frozen. > > You could get an input stream via the IO service and nsIChannel::Open, > but writing to files that way would be harder. (But those interfaces > would be the best way) Ok, thanks. > > And most importantly, does mode paramenter we need to pass when opening > > a file with nsILocalFile::OpenAnsiFileDesc() is supported by Windows? > > What should be the argument in case of Windows? I looked at prio.h, it > > just says that windows doesn't supports mode flags. > > Of the ANSI function? That parameter is a string, not a combination of > flags, and it is supported. If you want to write to the file, pass "w" > or "wb" here. It's just like the mode parameter of fopen. This function > maps pretty directly to _wfopen (of fopen, on older versions of Gecko or > on Win9x). I passed "rw". But still it's not working. I will try this later. > > Are there any C++ examples available for doing file I/O in XPCOM? > > These have examples, although they are for reading a file only: > http://developer.mozilla.org/en/docs/nsILocalFile:openNSPRFileDesc > http://developer.mozilla.org/en/docs/nsILocalFile:openANSIFileDesc Thanks a lot for the help. - Rajendra Prasad Murakonda, http://prodizy.livejournal.com/ _______________________________________________ dev-tech-xpcom mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-xpcom
