Current directory fix

Discuss development issues and submit patches here
Post Reply
twinsen
Posts: 109
Joined: Mon Dec 27, 2010 3:17 pm

Current directory fix

Post by twinsen »

Put directory containing Explorer++.exe in the path environment variable.

From command line:
"explorer++ ." does not open the current directory.

This patch fixes that.
Attachments
current_dir_patch_v156.7z
(738 Bytes) Downloaded 584 times
ajs
Posts: 409
Joined: Mon Jul 05, 2010 6:37 pm

Re: Current directory fix

Post by ajs »

Hi David,
patch which includes the change from twinsen. I slightly modified the code to better adhere to E++ command line parsing code. I also fix it so that it can handle the start from both drives and folders.
The patch is against commit 156 and includes all the previous patches made by me and twinsen so far.
Attachments
patch_09__v156.7z
(39.26 KiB) Downloaded 606 times
ajs
Posts: 409
Joined: Mon Jul 05, 2010 6:37 pm

Re: Current directory fix

Post by ajs »

Updated patch against commit 161.
This patch includes only the changes for this function, without any another change made.
Attachments
patch_09__v161.7z
(674 Bytes) Downloaded 608 times
ajs
Posts: 409
Joined: Mon Jul 05, 2010 6:37 pm

Re: Current directory fix

Post by ajs »

Commit 163 breaks the previous patch.
I have fixed the problem and re-created a patch against commit 163.

Patch file removed from here. Updated file can be found below
Last edited by ajs on Sun Jan 09, 2011 6:13 pm, edited 1 time in total.
twinsen
Posts: 109
Joined: Mon Dec 27, 2010 3:17 pm

Re: Current directory fix

Post by twinsen »

Your code changes doesn't work for ".."
find was used to handle both . and .. (and ..\otherDir), not sure of the equivalent c function to use instead yet, perhaps strstr?
and maybe switch the stream for sprintf

I also have fixed an issue for some directories with spaces (eg "c:\Program Files"). They seemed to have invalid characters in the string.

I haven't had time to patch the latest revision, but this is the code I am now using in 1.2:

Code: Select all

		else
		{
			TCHAR szParsingPath[MAX_PATH];
			TCHAR szCurrentDirectory[MAX_PATH];

			GetCurrentDirectory(SIZEOF_ARRAY(szCurrentDirectory),szCurrentDirectory);

			std::wstring wPath = szPath;
			if (wPath.find(TEXT("."))==0)
			{
				std::wstringstream buffer;
				buffer << szCurrentDirectory << "\\" << wPath;
				wPath = buffer.str();
				TCHAR* tPath = W2T((wchar_t*)wPath.c_str());
				StringCchCopy(szPath, _tcslen(tPath)*sizeof(TCHAR)+1, tPath);
			}

			DecodePath(szPath,szCurrentDirectory,szParsingPath,SIZEOF_ARRAY(szParsingPath));

			StringCchCopy(TabDirectory.Dir,SIZEOF_ARRAY(TabDirectory.Dir),szParsingPath);
			g_TabDirs.push_back(TabDirectory);
		}
Example exe:
http://members.iinet.net.au/~bertdb/rya ... n_1.5.2.7z


(edit)
I converted it to use wcscspn and StringCchPrintf instead and updated it to work with v187.

Code: Select all

		else
		{
			TCHAR szParsingPath[MAX_PATH];
			TCHAR szCurrentDirectory[MAX_PATH];

			GetCurrentDirectory(SIZEOF_ARRAY(szCurrentDirectory),szCurrentDirectory);

			if (wcscspn(szPath, _T("."))==0)
			{
				TCHAR szFullPath[MAX_PATH];
				StringCchPrintf(szFullPath, SIZEOF_ARRAY(szFullPath), _T("%s\\%s"), szCurrentDirectory, szPath);
				StringCchCopy(szPath, MAX_PATH, szFullPath);
			}

			DecodePath(szPath,szCurrentDirectory,szParsingPath,SIZEOF_ARRAY(szParsingPath));
			g_TabDirs.push_back(szParsingPath);
		}
Attachments
CurrentDirFix_v187_patch.7z
(525 Bytes) Downloaded 602 times
Last edited by twinsen on Sun Feb 06, 2011 9:01 pm, edited 4 times in total.
ajs
Posts: 409
Joined: Mon Jul 05, 2010 6:37 pm

Re: Current directory fix

Post by ajs »

twinsen wrote:Your code changes doesn't work for ".."
find was used to handle both . and .. (and ..\otherDir), not sure of the equivalent c function to use instead yet, perhaps strstr?
and maybe switch the stream for sprintf

I also have fixed an issue for some directories with spaces (eg "c:\Program Files"). They seemed to have invalid characters in the string.

I haven't had time to patch the latest revision, but this is the code I am now using in 1.2:
yes, it doesn't work for "..". I will check again and fix, possibly today.
ajs
Posts: 409
Joined: Mon Jul 05, 2010 6:37 pm

Re: Current directory fix

Post by ajs »

Hi David,
new patch 09 which handles starting parameters as ".", ".." and any path which starts with those strings.
Also, in Options -> Files and folders, changing the size of "show all file size in" will enable the "apply" button, without the need to change another option.
Attachments
patch_09__v163.7z
(1002 Bytes) Downloaded 566 times
David Erceg
Site Admin
Posts: 933
Joined: Sat Apr 18, 2009 1:46 am

Re: Current directory fix

Post by David Erceg »

Michael, your update to OptionsDialog.cpp is incorrect - it causes the apply button to activate when the drop down is clicked (regardless of whether the selection is changed). See WM_COMMAND within GeneralSettingsProc.
ajs
Posts: 409
Joined: Mon Jul 05, 2010 6:37 pm

Re: Current directory fix

Post by ajs »

David Erceg wrote:Michael, your update to OptionsDialog.cpp is incorrect - it causes the apply button to activate when the drop down is clicked (regardless of whether the selection is changed). See WM_COMMAND within GeneralSettingsProc.
David,
actually that was done on purpose. The reason for that is that if the "show all file size in" option is already enable, changing the size without changing anything else would not enabled the apply button. So if somebody wants to test a different size "on the fly" (i.e. without clicking on the OK button), he needs to enable/disable another option to enable the apply button.
I agree that enabling the apply button just clicking on the drop-down is not 100% correct, but thought if was a smaller problem compare the the original one.
Anyhow I will rework the patch to enable the apply button only when a different choice is made
ajs
Posts: 409
Joined: Mon Jul 05, 2010 6:37 pm

Re: Current directory fix

Post by ajs »

Hi David,
I have reworked this patch following your comments.
Attachments
patch_09__v186.7z
(1.66 KiB) Downloaded 544 times
Post Reply