|
You are not checking the response after each rename to see if it succeeded, nor are you showing the value of errno .
|
|
|
|
|
x=rename(orig,tempname); if(x) MessageBox(0,strerror(errno),"rename file",OUCH);
y=rename(cor,orig); if(x) MessageBox(0,strerror(errno),"rename file",OUCH);
z=rename(tempname,cor); if(x) MessageBox(0,strerror(errno),"rename file",OUCH);
For "x=rename(orig,tempname);" the error was "permission denied"!!! This is on my own computer at home.
Sorry. I misread the help file. I thought that rename() returned errno as its return value. Sorry.
modified 20-Jan-13 11:29am.
|
|
|
|
|
Yes, and in each case you are checking the variable x even though you use y and z to store the other return values. If you get "permission denied" (so errno is not -1), then you are trying to rename a file or directory for which you don't have access rights. What version of Windows is this?
|
|
|
|
|
> you are checking the variable x
Thanks Sorry.
#define OUCH MB_ICONEXCLAMATION
x=rename(orig,tempname); if(x) MessageBox(0,strerror(errno),"rename file",OUCH);
y=rename(cor,orig); if(y) MessageBox(0,strerror(errno),"rename file",OUCH);
z=rename(tempname,cor); if(z) MessageBox(0,strerror(errno),"rename file",OUCH);
> What version of Windows is this?
Windows Vista. Thanks for all your help and patience.
|
|
|
|
|
Anthony Appleyard wrote: Windows Vista. You will find that the C: directories have protected access. You can adjust the protection levels or run with Administrator privileges. A better idea is not to work there, but use one of your user library locations for your data files.
|
|
|
|
|
> You can adjust the protection levels or run with Administrator privileges
How do I switch to running in administrator mode?
The usual user mode that I am in when I start my PC, please how can I make that user authenticated?
When did all this about several users and an administrator start in desktop PC's? When desktop computers came in, I was thankful that at last I was master of my computer and free from complications of several users and usernames and having to appeal to an administrator for things like when a computer was as big as a car and needed its own room.
Which privilege does a user need to move a file using rename(,)? My program makes no objection about reading and writing to files in the C:\ area.
I have a very similar Visual C++ project which does not refuse to rename files in my C: area.
When my Visual C++ compiler is working on this program, do I have to click "Project" on the top menu and then Properties on the resulting dropdown menu to make that project compile a program with the privilege to move files?
I have seen many changes in computers. I remember when the fastest data link available to me between the two parts of the university that I worked in, was me walking along Upper Brook Street with a magnetic tape about a foot (= 30 cm) diameter under my arm.
modified 20-Jan-13 17:40pm.
|
|
|
|
|
Anthony Appleyard wrote: How do I switch to running in administrator mode? You can right click the program in Windows Explorer and click "Run as administrator". Alternatively you can use the Project Properties: select Linker -> Manifest File, and change the UAC Execution Level to either "highestAvailable" or "requireAdministrator". This is always assuming that you are already running under an account with administrator level access.
Anthony Appleyard wrote: When did all this about several users and an administrator start in desktop PC's? It started with Windows XP and gets progressively more sophisticated with Vista and Windows 7.
Anthony Appleyard wrote: I have a very similar Visual C++ project which does not refuse to rename files in my C: area. So it would be a good idea to investigate what is different between the two.
|
|
|
|
|
> You can right click the program in Windows Explorer and click "Run as administrator".
> Alternatively you can use the Project Properties: select Linker -> Manifest File,
> and change the UAC Execution Level to either "highestAvailable" or "requireAdministrator".
I just now tried all 3 of these and all got "Permission denied".
> This is always assuming that you are already running under an account with administrator level access.
Please, how do I set my PC's current account to administrator level access?
If there is a file whose full name is "C:\\zxcvbnm", please how can I find if it exists, and of so, if it is open to anything, and if so, to close it?
I remember from way back (it may have been when I was still using Borland C++ 5.1) that I had a program that faulted, and it behaved correctly after I changed its compiling-and-linking mode from 'dynamic' to 'static'. Please how can I do that now in my Visual C++ 2008?
I have just checked, and as far as I can tell, my PC has one user, which is "Owner Administrator".
modified 21-Jan-13 5:03am.
|
|
|
|
|
Anthony Appleyard wrote: how do I set my PC's current account to administrator level access? You should have done that at install time. If you have the password of the admin account then you should login to that account and then use Control Panel -> Users to set your own account to administrator level.
|
|
|
|
|
Anthony Appleyard wrote: The apostrophes are not in the strings. What about the single backslashes?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
> What about the single backslashes?
In the strings in the program, the backslashes are double.
|
|
|
|
|
errno does not have a value of -1.
|
|
|
|
|
Recapping scattered comments.
After EACH method call IMMEDIATELY check the return value.
if the return value is not zero then IMMEDIATELY call errno. Do NOT make any other API calls before calling errno.
So you code should look like the following (with the included suggestion of strerror
int ret = rename(...);
if (ret != 0)
{
int errNum = errno;
printf("Failed to rename %s", strerror(errNum));
}
|
|
|
|
|
I just found that I had fopen()'ed the same file twice without fclose()'ing it between. The offending rename(,)'s now work OK. I am sorry to take up so much of your time.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I just now inserted into my program this instruction:-
i=rename("C:\\Poser4\\Runtime\\Libraries\\character\\Divers\\Divers_rebreathers\\CDBA\\miaow.txt",
"C:\\Poser4\\Runtime\\Libraries\\character\\Divers\\Divers_rebreathers\\CDBA\\wuff.txt");
to rename a file which I had just created and the program never opens it. And the rename went OK.
The file that I was trying to rename it before :: I had fopen()'ed it in read mode, and read from it, and then fclose()'ed it; after that I tried to rename it, and that rename was refused.
modified 21-Jan-13 6:13am.
|
|
|
|
|
Hello, first of all I have to apologise if my question is stupid or asked in the wrong place.
I'm rather new to mpi and i just discovered how to achiave a topology aware communicator, using mpi_graph_create. The thing that I cannot seem to achieve is to track messages through said topology.
For example if I call MPI_Send/MPI_Recv is 2 "non-adjacent" processes, is there a way to check the route that message takes through the graph?
|
|
|
|
|
|
I have downloaded IVT library ( Integrating Vision Toolkit), I made my app dependent on this library ( as DSP project in VC6.0) , I can partially compile the app because I get “permission denied” when I get to #include preprocessor statement.
I have checked the directory permissions and I have grayed out “read only” checked in IVT directory.
All of the sources I used so far said that such grayed out “read only” checked ( in XP) does not make any difference (?) when directories are involved.
All of my app directories have that grayed out “read only” checked and I have no problem including other (OpenCV) libraries.
I am tempted to recopy / re-download the IVT files , but would like to hear from the forum what is going on here.
Appreciate any advise.
Cheers
Vaclav
Addendum
Here is the real code snippet
I must be doing something really stupid.
#pragma message("include IVT ")
#include <Z:\Program Files\IVT\ivt-1.3.19\IVT\src> // fails
#include <Z:\Program Files\IVT\ivt-1.3.19\IVT\src\Calibration> // fails
#include <Z:\Program Files\IVT\ivt-1.3.19\IVT\src\Calibration\Calibration.h> // OK
-- modified 19-Jan-13 13:10pm.
|
|
|
|
|
You cannot include entire directories.
|
|
|
|
|
How stupid of me, I have done some stupid things but this one takes the first dummy price! Thanks Richard.
|
|
|
|
|
Vaclav_Sal wrote: I have done some stupid things So have we all; it's a good learning experience.
|
|
|
|
|
Richard,
I spoke too soon.
Now I need to figure out how to unclude all the header files of SUBDIRECTORIES. I need the IVT library in debug mode.
Do I have to create my own parent #include file ( such as
stdafx.h) with all the other headers or is it a time to learn how to use CMake?
There is a Make file in the IVT stuff I dowloaded , but I never used Make.
Cheers Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Do I have to create my own parent #include file ( such as stdafx.h) with all the other headers or is it a time to learn how to use CMake? I'm not sure what you mean, the two are not connected. Using pre-compiled headers via stdafx.h merely helps to reduce the compile time of your source files, but you still need to #include all the individual header files. I have used make in the past and it is a good system, but I don't think it offers any advantages when you are creating Windows applications. Using the VS build system will do all you need.
|
|
|
|
|
One of the bygone useful features of the ancient days before DOS programming vanished, was ability, when I wanted to calculate something quickly, to quickly write a program where control started at the beginning and ran down the text like in a knitting pattern and and I did not have to catch Windows messages and events. A short example follows at the end of this message. Please, how can I use Visual C++ to write and run such a program, and how to run it? (I have Windows Vista).
#include <stdio.h>
#include <std.h>
int F; char s[256],*nl="\n";
void v(int i,int j){sprintf(s,"%1d,%-3d %c%c%c%c ",i,j,0xc0,j,i,0xc0);
write(F,s,11);}
main(){int i,j; F=open("t$$",0x8002);
for(j=0;j<=84;j++) v(4,j); write(F,nl,1);
for(j=0;j<=34;j++) v(5,j); write(F,nl,1);
for(j=0;j<=234;j++) v(6,j); write(F,nl,1);
close(F);}
|
|
|
|
|
Just set your project to "Console application".
|
|
|
|
|
I am writing a Visual C++ program, using features from an from an older Visual C++ program which I wrote. How can I (for example) get the compiler to use the version of the standard function GetFileName(.....) which needs a char* parameter rather than the version which needs a WCHAR* parameter?
|
|
|
|
|