Skip to content

Fix utf-8 char path in windows #1002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

npes87184
Copy link
Contributor

The file 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server'
exists, however, it will show msg as follow:

INFO: scrcpy 1.12.1 https://github.com/Genymobile/scrcpy
stat: No such file or directory
ERROR: 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server' does not
exist or is not a regular file
Press any key to continue...

This patch fixes it.

Signed-off-by: Yu-Chen Lin [email protected]

Copy link
Collaborator

@rom1v rom1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, well spotted!

Thank you for the fix! 👍

@@ -208,8 +208,23 @@ process_check_success(process_t proc, const char *name) {

bool
is_regular_file(const char *path) {
#ifdef __WINDOWS__
Copy link
Collaborator

@rom1v rom1v Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For command.c, there are platform-specific implementations in sys/win/ and sys/unix/.

Since the implementation is now (almost) totally different, I think the function can be moved there (without additional ifdef).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see new version.

The file 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server'
exists, however, it will show msg as follow:

INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
stat: No such file or directory
ERROR: 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server' does not
exist or is not a regular file
Press any key to continue...

This patch fixes it.

Signed-off-by: Yu-Chen Lin <[email protected]>
@rom1v
Copy link
Collaborator

rom1v commented Dec 13, 2019

Thank you.

However, I fail to make it work on Windows.

I declared the environment variable SCRCPY_SERVER_PATH (in the system preferences) to C:\Users\user\Downloads\scrcpy-win64-v1.12.1\论\scrcpy-server (where I put the file).

When I execute scrcpy.exe (built with this patch):

C:\Users/user/Downloads/scrcpy-win64-v1.12.1>scrcpy
INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
stat: No such file or directory
ERROR: 'C:\Users\user\Downloads/scrcpy-win64-v1.12.1\?\scrcpy-server' does not exist or is not a regular file
Press any key to continue...

(If I rename to some ASCII text, it works)

Signed-off-by: Yu-Chen Lin <[email protected]>
@npes87184
Copy link
Contributor Author

Thank you for your testing.

There are two problems here.

  1. The path sent to is_regular_file does not handle non-ascii.
  2. The env variable needs to consider non-ascii case.

I have a computer which will get absolute path from get_server_path, if the path contains non-ascii text, it will failed to stat, this problem fixed by 71db667.

However, if I set env variable as your testing method, it does not work again. After digging on it, I found the problem is due to the getenv. This problem fixed by 2639c6a.

Thanks.

@rom1v
Copy link
Collaborator

rom1v commented Dec 14, 2019

Oh thank you 👍

There was a problem with get_server_path(), which sometimes returned an allocated string, sometimes not. I fixed it beforehand: 7d58451

Then I rebased your commit and edited the last one. Please review pr1002 (and test it if you can, I did my own tests, but I'm not sure they are exhaustive).

@npes87184
Copy link
Contributor Author

I have tested on my computer, everything works!
Also, the patches look good to me.

Thank you.

rom1v added a commit that referenced this pull request Dec 15, 2019
Fix utf-8 char path in windows

<#1002>
@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2019

👍 Thank you very much.

Merged into dev.

@rom1v
Copy link
Collaborator

rom1v commented Apr 29, 2020

Released in v1.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants