file-manipulation

In-memory XML manipulation

I'm trying to do a find and replace in an OpenXML word document which I've openened into a MemoryStream. using (WordprocessingDocument _document = WordprocessingDocument.Open(_ms, true)) { var placeHolder = _document.MainDocumentPart.Document .Descendants<DocumentFormat.OpenXml.Wordprocessing.Text>() ...

How can I alter a file and write only the changes to disk - basically, sed (python)?

Let's say I have a file /etc/conf1 it's contents are along the lines of option = banana name = monkey operation = eat and let's say I want to replace "monkey" with "ostrich". How can I do that without reading the file to memory, altering it and then just writing it all back? Basically, how can I modify the file "in place"? ...

How to associate a 4-char OSType / NSFileHFSTypeCode with a particular UTI

I am writing a MacFuse plugin, and would like finder to use the appropriate icons & launch the appropriate app when a file is opened. It is not possible for me to add an extension to the file, so my only other option in Snow Leopard is the NSFileHFSTypeCode. I have reviewed all of the codes registered on my machine using http://www.rub...

read, edit & save config files (php)

I have two configuration files. One is ini one is php. They look like below. I need to update the database file name but the rest of the files must be unchanged. Any idea how to do so? config.ini ; Turning Debugging on [test] developer = true ; Production site configuration data [production] database.params.dbname = /var/lib/firebir...

Merge PDF files

Hi all, I did a search and nothing really seemed to be directly related to this question. Is it possible, using Python, to merge seperate PDF files? Assuming so, I need to extend this a little further. I am hoping to loop through folders in a directory and repeat this procedure. And I may be pushing my luck, but is it possible t...

python to uncomment the right line

Hi, guys, I have a file as follows: line 1: _____ ... # for AAA #export CONFIG = AAA_defconfig # for BBB, BbB, Bbb, BBb3 #export CONFIG = BBB_defconfig # for CCC, CcC, Ccc, Ccc1 #export CONFIG = CCC_defconfig ... other lines I want manipulate the file, so that based on the given string, I could export the right "CONFIG", and...

Any reason why an std::ofstream object won't close properly?

I noticed in my C++ code that anytime I close an std::ofstream object I'm unable to reopen the file I closed with std::ifstream. std::ifstream's open function will always fail. Is there anything 'extra' I can do to ensure that my std::ofstream object closes properly? Someone's probably going to ask to see my specific code so for the sa...