fopen

_wfopen equivalent under Mac OS X

I'm looking to the equivalent of Windows _wfopen() under Mac OS X. Any idea? I need this in order to port a Windows library that uses wchar* for its File interface. As this is intended to be a cross-platform library, I am unable to rely on how the client application will get the file path and give it to the library. ...

How do I use scanf() with fopen

I'm writing a program and am having trouble using the scanf and fopen working together. From what I can tell my erroneous lines seems to be: FiLE * DataFile DataFile = fopen("StcWx.txt","r"); scanf(DataFile, "%i %i %i %.2f %i %i", &Year, &Month, &Day, &Precip, &High, &Low); The file it opens from has a list of weather data that look...

End of FILE* pointer is not equal to size of written data.

Very simply put, I have the following code snippet: FILE* test = fopen("C:\\core.u", "w"); printf("Filepointer at: %d\n", ftell(test)); fwrite(data, size, 1, test); printf("Written: %d bytes.\n", size); fseek(test, 0, SEEK_END); printf("Filepointer is now at %d.\n", ftell(test)); fclose(test); and it outputs: Filepointer at: 0 Writte...

Overwite Line in File with PHP

What is the best way to overwrite a specific line in a file? I basically want to search a file for the string '@parsethis' and overwrite the rest of that line with something else. ...

Is there a standard way to do an fopen with a unicode string file path?

Is there a standard way to do an fopen with a unicode string file path? ...

Does PHPs fopen function implement some kind of cache?

I'm struggling with the automated data collection of a PHP script from a webserver. The files in question contain meteo data and are updated every 10 minutes. Weirdly enough, the 'file modified' date on the webserver doesn't change. A simple fopen('http://...')-command tries to get the freshest version of the last file in this directory...

How do I open a file from line X to line Y in PHP?

The closest I've seen in the PHP docs, is to fread() a given length, but that doesnt specify which line to start from. Any other suggestions? ...

How do you resolve a hidden javascript link with php?

Hi, I'm trying to parse a bunch of webpages one after the next with PHP, but I noticed that when I fopen the first page, the links to the following pages are hidden in javascript. Is there anyway I can continue on to parse the next webpages? If the url had a variable like "page=2" encrypted into it I would go through them that way, bu...

PHP can't read files containing PHP code as text files

I've stumbled upon the following pecularity: $handle = fopen(realpath("../folder/files.php"), "r"); can't read a file, but as soon as I remove php tags from the file, it becomes readable and my scripts prints non-empty file content on the page. Also, file.php is never ever executed, so I wonder why it is the problem. I guess somehow A...

ASP.Net app calling DLL with fOpen...

Hello, I have ASP.Net web app and my c# code calls into a custom COM DLL. The DLL was written awhile back and uses fOpen. he fOpen calls return a NULL pointer. I am suspecting it is permissions, but I am having no luck in recolving the issue. Can anyone give me any ideas of what to do? Can fOpen be used? Are there special permissi...

Sqlite as a replacement for fopen() ?

On an official sqlite3 web page there is written that I should think about sqlite as a replacement of fopen() function. What do you think about it? Is it always good solution to replece application internal data storage with sqlite? What are the pluses and the minuses of such solution? Do you have some experience in it? EDIT: How abo...

PHP fopen() Redirection Limit Reached Error

When executing the following block of code: foreach($eventfiles as $eventfile) { if($eventfile['filename']) { $file = $eventfile['filepath']; // Open File if( !($fp = fopen($file, "r"))) { echo '<br>CAN NOT READ FILE.'; exit; } // Read data from the file into $data $data = ""; wh...

file_get_contents (or curl, or fopen) problem with session data.

hello, i have a page that shows a value from session, lets call it www.domain-a.com/master.php and if i type it directly from the browser, it shows me the session value. but when i try to download it with file_get_contents (or other method) from another domain, like www.domain-b.com/slave.php, it is not retrieving the content protected...

In php, I want to download an s3 file to the browser without storing it on my server

I've got files on Amazon's S3. They are named with a unique ID so there are no duplicates. I am accessing them using an authorized URL. I need to be able to pass them through to the browser, but I need to rename them. Right now I'm using fopen, but it is downloading the file to my server before serving the file to the browser. How can I ...

Contingency plan for fopen error in php

I'm writing a PHP app that has a 'control panel' that writes a prefs file with certain variables. On every POST, if the file doesn't exist, it is created. If it does exist, it is unlinked and a new file is touched with the same filename and new variables. This file is then included on another page with displays content based on the varia...

PHP fopen function timed out?

any idea why fopen would timeout for a file if it is on my server and I know the url is correct? update: sorry, i should have mentioned this is in php. the code is: fopen($url, 'r'); It works if i put in a relative path for the file, but not if $url is a url in my server (but it works for google.com). Thanks for the help. Alaitnik's...

error on using @fopen

I'm using @fopen to open a file in "rb" mode. the file that im opening here is running with no errors but if i open that file using @fopen then it is giving error. code is something like this--- $file = @fopen("xyz.com","rb") or $flag=1; if($flag==1) { mail($to, $subject, $message, $from); die(); } sometimes it opens up wit...

Warning on PHP fopen

$file = @fopen("http://ajax.htm","rb"); I am getting this error while using fopen Warning: fopen(xyz.htm): failed to open stream: HTTP request failed! in /home/user/public_html/aaa/ttt.php on line 8 what could be the reason behind this? ...

fopen non-ascii character error

i cannot use fopen on files includes in their name some characters (example : ş, ç, ı) how can i use fopen on these files ? i'm using vc++ 6 (i have to) and c language. when i was trying to use _wfopen it's never open any file. ...

What about a string value retrieving speed with fopen, mysql query, include/require

Hi, That´s a general question. I need do retrieve the value of about 20 strings of about 100 characters each. Which of the following methods would be the quickest, in order to retrieve the variables? 1) reading from a separate include file, where the variables values are assigned (e.g. $var1 = "blablablah...."; etc) 2) reading from a t...