this isn't a particularly good variable name:
>+ PRUint32 per;
>+ if (!user) {
indentation following this line is confused, it should be 4-4, but for some reason you're doing something else:
>+ user = PR_GetEnv("USERNAME");
>+ if (!user || !*user) {
>+ user = PR_GetEnv("USER");
>+ if (!user || !*user) {
>+ user = PR_GetEnv("LOGNAME");
Comment on attachment 428479
Patch;Please Comment
>+ PRBool isWritable = PR_FALSE, isExecutable = PR_FALSE;
please include spaces around (=):
>+ PRInt16 i=1;
this isn't a particularly good variable name:
>+ PRUint32 per;
>+ if (!user) {
indentation following this line is confused, it should be 4-4, but for some reason you're doing something else: "USERNAME" ); "LOGNAME" );
>+ user = PR_GetEnv(
>+ if (!user || !*user) {
>+ user = PR_GetEnv("USER");
>+ if (!user || !*user) {
>+ user = PR_GetEnv(
if this fails, things are strange.
>+ }
>+ }
>+ }
>+ nsDependentCString path(tPath);
>+ nsDependentCString tem;
we don't typically use nsDependent*String for string operations:
>+ path += "mozilla-";
instead, you can use ns*(Auto)String
>+ path += user;
>+ rv = NS_NewNativeLoc alFile( path,PR_ TRUE,aFile) ;
>+ while (!isExecutable || !isWritable) {
You didn't check isSymLink: ->Exists( &isExecutable) ;
>+ ((nsILocalFile *)*aFile)
>+ if (isExecutable) {
you should check the return value of xpcom method calls. perhaps the function you're calling failed: ->GetPermission s(&per) ;
>+ ((nsIFile *)*aFile)
again, your indentation is strange: ?PR_TRUE: PR_FALSE;
>+ isWritable = (per == PR_IRWXU)
>+ if (!isWritable) {
Use .Truncate() instead, SetIsVoid is for very very rare cases: PR_TRUE) ;
>+ tem.SetIsVoid(
We have a nsIFile. createUnique, you might want to use that instead: i,10);
>+ tem.AppendInt(
generally you should have spaces after commas: alFile( tem,PR_ TRUE,aFile) ;
>+ rv = NS_NewNativeLoc
You can't do this, you need to use do_QueryInterface:
>+ ((nsILocalFile *)*aFile)->
What happens if the file system is FAT/NTFS or something similarly exotic?