file-handling

File can be opened only by root user..Wrong permisssions given, i guess....

My program basically runs a executable file with command line arguments. A child process is forked and the output of the child process is taken in the file "filename". The problem is that the file is made and the data is written but it can only be opened by the root user.. How can make it readable to the user who invoked the program? T...

Reading Data from File in Objective-C

Hello, I want to read the string after delimiter from a text file in Objective-C.i'm stil struggling to get it :(.... This is wat i ve done til nw, but when i print the contents of databuffer in line 7 in code below, the data read is returning encapsulated in an NSData object.How to convert it into Readable format? NSData *databuffer;...

Why do I get a SIGABRT here?

I have this code segment in which I am opening/closing a file a number of times (in a loop): for(i=1;i<max;i++) { /* other code */ plot_file=fopen("all_fitness.out","w"); for (j=0;j<pop_size;j++) fprintf(plot_file, "%lf %lf\n",oldpop[i].xreal[0],oldpop[i].obj); fclose(plot_file); /*other c...

Write text files without Byte Order Mark (BOM) ?

I am trying to create a text file using VB.Net with UTF8 encoding, without BOM. Can anybody help me, how to do this? I can write file with UTF8 encoding but, how to remove Byte Order Mark from it? Thanks in Advance. edit1: I have tried code like this; Dim utf8 As New UTF8Encoding() Dim utf8EmitBOM As New UTF8Encoding(True) ...

What's the best strategy to delete a very huge folder using Perl?

Hi, I need to delete all content (files and folders) under a given folder. The problems is the folder has millions of files and folders inside it. So I don't want to load all the file names in one go. Logic should be like this: iterate a folder without load everything get a file or folder delete it (verbose that the file or folder "...

feof() in C file handling

I am reading a binary file byte-by-byte,i need determine that whether or not eof has reached. feof() doesn't works as "eof is set only when a read request for non-existent byte is made". So, I can have my custom check_eof like: if ( fread(&byte,sizeof(byte),1,fp) != 1) { if(feof(fp)) return true; } return false; But the probl...

How do I load resource using Class Loader as File?

I want to open files using the class loader. However I always get a FileNotFoundException. How do I create a new File using the URL? I don't want to open it as a stream just as a file. URL url = VersionUpdater.class.getResource("xslt/screen/foo"); File f = ... ...

c source code to remove subset transactions from text file

I have a file containing data as follows 10 20 30 40 70 20 30 70 30 40 10 20 29 70 80 90 20 30 40 40 45 65 10 20 80 45 65 20 I want to remove all subset transaction from this file. output file should be like follows 10 20 30 40 70 29 70 80 90 20 30 40 40 45 65 10 20 80 Where records like 20 30 70 30 40 10 20 45 65 20 are rem...

Reading data file into an array C#

I have an array like this: int[,] iMap = new int[iMapHeight, iMapWidth] { { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {...

Force an OleDbConnection to Release a File Handle

Related Question My code doesn't release a file handle even after I call dispose to an initialized OleDbException. Is there a way to explicitly force the program to release a file handle? ...

How to know the file type of the file which you are forcing the user to download?

I am trying to force the user to download a file. For that my script is: $file = "file\this.zip"; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$file"); header("Content-Type: application/zip"); //This is what I need header("Content-Transfer-Encodi...

Difference between '>>' and '>' in Perl

What is the difference between these two code snippets? open (MYFILE, '>>data.txt'); open (MYFILE, '>data.txt'); ...

How to create a file in remote host along with the creation of directory using ssh

Hello, I have a file say /a/b/c/file in my host. I want to create a file on remote host in directory say dest. Now the question is, how do I create a file in remote host as /dest/a/b/c/d/file using perl script and using ssh. Any idea how do I create directories in script.? Thanks. ...

perl - file handling

Hi, I have a list of files on host machine say in directory /src/. The directory has more subdirectories. now this directory is copied onto remote machine after mounting. Now the files are preset in remote machine in directory /dst. Example. If I had /src/a/f1, /src/b/f2 I will have on remote machine /dst/a/f1 ,/dst/b/f2 Now I only ha...

ssh problem - no such file or directory

Hello, I have a script in remote host which I run as ./test /a/b/c/f and it runs perfectly fine on the maching. Now I am on host machine, I run the same script as ssh root@dst "./test /a/b/c/f" and this too runs fine. But from my perl script I execute it using backticks as $file = "/a/b/c/f"; `ssh root\@dst "./test $file"`; or sys...

file handling routines on Windows

Is it allowed to mix different file handling functions in a one system e.g. fopen() from cstdio open() from fstream CreateFile from Win API ? I have a large application with a lot of legacy code and it seems that all three methods are used within this code. What are potential risks and side effects ? ...

How do I open a file whose full name is unknown with Perl?

I want to know if there is anything that lets me do the following: folder1 has files "readfile1" "f2" "fi5" The only thing I know is that I need to read the file which starts with readfile, and I don't know what's there in the name after the string readfile. Also, I know that no other file in the directory starts with readfile. How d...

How to check session when downloading uploaded file in cakephp?

Hi there, I have created a feature to upload and download file in my site. But I want to validate the download feature. I want to allow a user to download file if user is already logged in to my site and given permission to download. Help me. How to check whether session is present there or not? I am uploading files in /app/webroot/doc...

Clarification required against this piece of code in Java

Hi, when I write this piece of String path="d:\\test.txt"; boolean chk; File f=new File(path); try { chk=f.createNewFile(); }catch(IOException e) { chk=false; e.printStackTrace(); } if(chk) System.out.println("file created."); else System.out.println("file ...

Handling many image files in scrollview on iPhone similar to photos app

So I've seen this question asked before and in fact I asked it last night but I thought I'd give it another go just to see if I could get any other unique views on the problem. The Problem — I have an app with a large number of uiimageviews (with image downloaded to disk) in a scrollview which of course has two large problems facing it:...