Reputation: 1
I have written a simple python script to delete older revision history from '.h' or '.c' file.
Here is code:
import mmap
f = open("D:\MyFile.h", "r+");
m = mmap.mmap(f.fileno(), 0);
index = m.find("/*+- Revision History");
if (index):
print index;
f.seek(index);
f.truncate();
f.close();
It gives the following error:
Traceback (most recent call last):
File "C:/Python27/Omni", line 15, in <module>
f.truncate();
IOError: [Errno 13] Permission denied
Upvotes: 0
Views: 1207
Reputation: 1
I successfully ran the same program on ubuntu and it works perfectly fine. I guess there is something to do with windows permission.
Upvotes: 0
Reputation: 501
please change the mode to open the file like this
f = open("D:/MyFile.h", "r+");
f.truncate()
f.close()
since you didnt have write permission on that file, it was getting that error. hope this will resolve the issue.
Hope you are using windows system. Then follow the above step. It worked for me.My python version is 2.6.
since you want to do truncate that removes all data from the file, it needs write permission, so I used r+
.
Upvotes: 1