files

Enter custom file name to be read ?

Hello, I want to allow users to type the name of any .txt file to be read/written. This is my code : printf("Enter .txt file name\n"); scanf("%s",&fname); FILE *inputf; inputf=fopen(&fname,"w"); Problem is this method does not work (having &fname) as a parameter. I can imagine its because C needs "filename.txt" for it work...

List of open files held by a process?

I am just starting off with C#. I managed to get a list of running processes and getting a particular process ID. Can someone tell me how to get a list of files that are opened by a given process ID? ...

Serving files with Turbogears2

How do I serve files from an arbitrary directory with Turbogears2? I have a database with the local path, e.g. /home/myuser/tg2env/MyProject/myproject/files/somefile.jpg tg.url seems to only be able to serve things from the public directory. Is there a widget available, or do I need to write some sort of DownloadController? ...

read from file after calling lseek64 - Linux

Hi, I'm trying to read a large file (> 2.0 GB). The seeking is done by lseek64, then I tried to read using read(fileHandle, buffer, bufferLength)\ pread64(fileHandle, buffer, bufferLength, offset) - but both return with -1. What could it be? Thanks in advance! ...

How can I detect dos line breaks in a file?

I have a bunch of files. Some are unix line endings, many are dos. I'd like to test each file to see if if is dos formatted, before I switch the line endings. How would I do this? Is there a flag I can test for? Something similar? ...

Where are the .framework files?

Hi, I am wondering where the .framework files are located. I am using Mac OS 10.6. If this is more of a Superuser question just tell me because I was having trouble determining whether to put it here or Superuser or here but it seemed like it should go here. ...

Split user.config into different files for faster saving (at runtime)

In my c# Windows Forms application (.net 3.5 / VS 2008) I have 3 settings files resulting in one user.config file. One setting file consists of larger data, but is rarely changed. The frequently changed data are very few. However, since the saving of the settings is always writing the whole (XML) file it is always "slow". SettingsSmall...

Read a file from line X to line Y ?

Hello, Is there a way to read a file in PHP5 from line X to line Y into a string, without reading the entire file. I would like to return huge files (10,000+ lines) using ajax requests. Each request will provide the client with additional lines. And due to the fact that the file can reach large sizes, I would like to avoid reading it w...

Scan Numbers among letters in a Sentence

Hello, I have a pretty easy question. (using C) In a sentence such as In this document, there are 345 words and 6 figures How can I scan 345 and 6 while ignoring all that is in between ? I tried fscanf(FILE *pointer,"%d %d",&words,&figs); But it only gets the first value ... What am I doing wrong ? EDIT Im sorry I forgot to ment...

Options for header in raw byte file.

I have a large raw data file (up to 1GB) which contains raw samples from a USB data logger. I need to store extra information relating to the file (sample rate, description, trigger point, last seek position etc) and was looking into adding this as a some sort of header. The header file should ideally be human readable and flexible so...

Load a file in a group objective-c Xcode

I'd like to load a file from a specific Group in Xcode/Objective-c for example: I have TWO files named "SomeFile.txt" that are in two different folders (folders not groups yet) in the OS: SomeFolderOne |- SomeFile.txt SomeFolderTwo |- SomeFile.txt Inner Xcode I make two folders, and I put a REFERENCE to these two files: SomeGroupOn...

Implement "Open Containing Folder" and highlight file

This can be a handy functionality to have in a program that works with files/folders. It's easy enough to actually open the containing folder using: System.Diagnostics.Process.Start( *path to folder* ); ...but how do I go about actually selecting the target file within that parent folder? If I use the Process.Start method it actually ...

Require_once to variable

I want to call require_once("test.php") but not display result and save it into variable like this: $test = require_once('test.php'); //some operations like $test = preg_replace(…); echo $test; Is it possible? ……………………… Thank you guys! :) Solution: test.php <?php $var = '/img/hello.jpg'; $res = <<<test <style type="text/css">...

RealPath returns an empty string

Hello all, I have the following which just loops through the files in a directory and echo the file names. However, when I use realpath, it returns nothing. What am I doing wrong: if ($handle = opendir($font_path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "a.zip") { ...

How can i Rollback for files/folders corresponding to the changes done?

I am using PHP and Mysql I have PHP script in which I rollback all the data in the database such data all the old value be reset to the database if update is done, and all new value gets deleted if new insert has been done. Now my goal is to perform the same process with files/folders associated with the changes done, I am not able to ...

Open existing file, append a single line

I want to open a text file, append a single line to it, then close it. ...

iPhone SDK - Accessing other Application Folders

Hello everyone, I know that you can access your own application files using NSDocumentDirectory and such, but can you do that on other applications. For example, if I wanted the Documents of another application, would it be possible to get that information? From the iPhone OS Library as directed here. Sincerely, Kevin ...

testing directory S_ISDIR acts inconsistently

hi, I'm doing simple tests on all files in directory. But from some reason, sometimes, they behave wrongly? What's bad with my code? using namespace std; int main() { string s = "/home/"; struct dirent *file; DIR *dir = opendir(s.c_str()); while ((file = readdir(dir)) != NULL){ struct stat * file_info = new (struct stat...

binary files writing/reading problems...

Ok i have problem with my code for reading binary file... First i will show you my writing code: void book_saving(char *file_name, struct BOOK *current) { FILE *out; BOOK buf; out = fopen(file_name, "wb"); if(out != NULL) { printf_s("Writting to file..."); do { if(current != NUL...

How can I use Perl to determine whether the contents of two files are identical?

This question comes from a need to ensure that changes I've made to code doesn't affect the values it outputs to text file. Ideally, I'd roll a sub to take in two filenames and return 1or return 0 depending on whether the contents are identical or not, whitespaces and all. Given that text-processing is Perl's forté, it should be quite e...