file

Dumping bits/bytes to a file in binary mode

Hello, I have below code. FILE *fp; int a; fp=fopen("dump.bin","wb"); a = 0xffafbcdf; fprintf(fp,"%x",a&0x3ffff); I am trying to dump only 18 LSBits of variable a. But the value dumped in the file is 3bcdf. My question - Is it not possible to dump/fwrite/fprintf desired number of bits which is not a multiple of 4(nibble) to...

How to read string literals and comments from a text file?

We are taking input from a text file. Every line is split in strings at white spaces, so we can further classify the elements. Making the string the problem is, that I also want to read string literals (e.g. "Thank you") as they are without splitting and comments too (both // and /* ....*/). Is there any way I can do this? ...

Clean up your #include statements?

How do you maintain the #include statements in your C or C++ project? It seems almost inevitable that eventually the set of include statements in a file is either insufficient (but happens to work because of the current state of the project) or includes stuff that is no longer needed. Have you created any tools to spot or rectify proble...

How to monitor file locking to track down a deadlock?

Our application is occasionally hanging while it saves, where the core data raw file is being left locked (perhaps by our spotlight importer). We've verified that it's at a low-level file level, not at the core data level. What I'm trying to do is figure out how to monitor the application while it's running so if I get this hang, I can...

.NET: How to print files w/o opening them

Hello, We have an application that basically archives files and we give the user the possibility to print these files. They can be .txt, .doc, .pdf, .jpg nothing fancy. Is there a .NET way to send these files to the printer without handling them further, ie opening them? I already tried creating a process with the StartInfo.Verb = "pri...

Is the expected time shown during file copy the best time or worst time?

When we copy files in windows, we get an expected time of completion. Is that time the best time or the worst time? Also are you assuming the environmental variables? ...

How to write binary data to a file so that it can be read fast back [gcc/C++]?

I need to write a file format that writes out data to a file and can read it back. It should be able to read the data back fairly fast, which should involve blitting a large block of data into a std::vector (since their storage is always implemented contiguously). However, when writing the file, I have no idea how to enforce constraint...

Simple Powershell lastwritetime compare

I need a Powershell script that can access a file's properties and discover the LastWriteTime property and compare it with the current date and return the date difference. I have something like this... $writedate = Get-ItemProperty -Path $source -Name lastwritetime ...but I can not cast the lastwritetime to a "DateTime" datatype. It...

PHP: reading config.ini to array with file()

My config file looks like this: title = myTitle; otherTitle = myOtherTitle; when I read the file with file(), it creates this array [0] => title = myTitle; [1] => otherTitle = myOtherTitle; and what I want the array to look like is [title] => myTitle; [otherTitle] => myOtherTitle; Am I using the wrong approach her? Should i just...

How to make "webmail"-like file attaching/uploading

Hello I want to implement file uploading with behaviour which is commonly seen in various kinds of webmail interfaces. I mean here that attachment (one or more) are selected by open file dialog and then their names are apearing under (for example) text area with body of message. And there is only info that attachment is added and it be ...

How do I check if a file is under a given directory, in PowerShell?

I want to check if a file path is in a given directory (or one of its subdirectories), from PowerShell. Right now I'm doing: $file.StartsWith( $directory, [StringComparison]::InvariantCultureIgnoreCase ) but I'm sure there are better ways. I could do take $file.Directory and iterate over all .Parents, but I was hoping for something...

handle a file upload from a html page to a separate .NET page

I want to upload a file from a web application. The web application calls web services to access .NET classes, but it's not a .NET application itself. What I want to do is this: upload a file from the web application, and call a separate .NET page to process and handle the uploaded file. It would be easy to do this if I used a php sc...

Java access to big file

I am looking for an efficient way to create a file whose size is unknown but can range from mb's to gb's and fill its content randomly. I may write first 200 bytes than jump to the end and write last 200 bytes and move to the middle and write there. Is RandomAccessFile efficient for doing this or are there any alternatives better suited ...

How can I randomly sample the contents of a file?

I have a file with contents abc def high lmn ... ... There are more than 2 million lines in the files. I want to randomly sample lines from the files and output 50K lines. Any thoughts on how to approach this problem? I was thinking along the lines of Perl and its rand function (Or a handy shell command would be neat). Related (Poss...

Differentiate between a unix directory and file in C++

Given a path, say, /home/xyz/abc/def, I would want to determine if def is a directory or a file. Is there a way of achieving this in my C++ code? ...

mysql select into outfile /tmp no output

Hello, I cannot get the following code to generate any output. The MySQL user has "all" grant level, /tmp is writable, the query returns a results set. mysql> SELECT field FROM test_table WHERE condition='test' -> INTO OUTFILE '/tmp/test.csv' -> FIELDS TERMINATED BY ',' -> ENCLOSED BY '"' -> LINES TERMINATED BY '\n'; ...

JMS File Store tuning

We are using Weblogic JMS as the JMS provider for our application. We use file store as the persistent store. Is there any mechanism to condfigure the file store size so that after the file has reached the specified size, a new file is generated. Right now I have seen that all the messages till today are persisted into one single file. I...

Record file copy operation with Git

When I move a file in git using git-mv the status shows that the file has been renamed and even if I alter some portions it still considers to be almost the same thing (which is good because it lets me follow the history of it). When I copy a file the original file has some history I'd like to associate with the new copy. I have tried...

Photos and Database

Hi Friends, I am working on a website, where user can upload photos of product they want to advertise. I am saving photos in a folder on the web. In the table where I keep reference of photos, there is a key field photoid which is Identity field(primary key). My repository has following methods Photo photo = rep.NewPhoto(); photo.Titl...

File write in C confusion

Hi I am appending at the bottom of the text file this works on windows but on linux instead of appending to the bottom it appends to the top of the text file. The code i am using is. The code must only use C FILE *fout; fout = fopen("dat.txt","a"); fprintf(fout,"&& "); fclose(fout); Please help. Thank you ...