Skip to content
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

Working with international accounts names on windows #940

Closed
sepavel opened this issue Jul 2, 2019 · 3 comments
Closed

Working with international accounts names on windows #940

sepavel opened this issue Jul 2, 2019 · 3 comments
Assignees
Labels
Windows Issues/problems specifically related to Windows
Milestone

Comments

@sepavel
Copy link

sepavel commented Jul 2, 2019

Hello,

PIVX can't work on windows with accounts that contains non latin symbols.
These symbols appears in paths like c:\Users<accountname>\AppData\Roaming

There are several code pieces that can be easily fixed by replacing Winapi A to W functions and char to wchar_t correspondenly

  1. src\util.cpp
    boost::filesystem::path GetTempPath()
    ..
#ifdef WIN32
    char pszPath[MAX_PATH] = "";

    if (GetTempPathA(MAX_PATH, pszPath))
        path = boost::filesystem::path(pszPath);
#else
  1. src\util
    boost::filesystem::path GetDefaultDataDir()
    ...
#ifdef WIN32
    // Windows
    return GetSpecialFolderPath(CSIDL_APPDATA) / "NetboxWallet";
#else

...

But there is one place where I don't know what to do to provide working patch
in src\init.cpp

    // Make sure only a single process is using the data directory.
    boost::filesystem::path pathLockFile = GetDataDir() / ".lock";
    FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
    if (file) fclose(file);
    static boost::interprocess::file_lock lock(pathLockFile.string().c_str());

    // Wait maximum 10 seconds if an old wallet is still running. Avoids lockup during restart
    if (!lock.timed_lock(boost::get_system_time() + boost::posix_time::seconds(10)))
        return InitError(strprintf(_("Cannot obtain a lock on data directory %s

because boost::interprocess::file_lock didn't work with wide char names but only with char and paths with non latin symbols will be corrupted

Questions? Advices? Ideas?

Regards,
Pavel

@Warrows
Copy link

Warrows commented Jul 3, 2019

I think you'll find that interesting: boostorg/interprocess#28

@Fuzzbawls Fuzzbawls added the Windows Issues/problems specifically related to Windows label Jul 4, 2019
@Fuzzbawls Fuzzbawls added this to the 4.0.0 milestone Jul 11, 2019
@Warrows Warrows self-assigned this Sep 13, 2019
@Warrows
Copy link

Warrows commented Sep 13, 2019

We probably need to backport most stuff from bitcoin#13869

@random-zebra random-zebra modified the milestones: 4.0.0, 4.1.0 Nov 25, 2019
@random-zebra random-zebra modified the milestones: 4.1.0, Future Mar 30, 2020
@random-zebra random-zebra modified the milestones: Future, 5.0.0 Apr 24, 2020
@furszy furszy modified the milestones: 4.2.0, Future Jul 1, 2020
random-zebra added a commit that referenced this issue Aug 5, 2021
63e0be6 [Remove] By-pass logprint-scanner restriction. (furszy)
280ced3 utils: Fix broken Windows filelock (Chun Kuan Lee)
be89860 utils: Convert Windows args to utf-8 string (Chun Kuan Lee)
e8cfa6e Call unicode API on Windows (Chun Kuan Lee)
1a02a8a tests: Add test case for std::ios_base::ate (Chun Kuan Lee)
2e57cd4 Move boost/std fstream to fsbridge (furszy)
9d8bcd4 utils: Add fsbridge fstream function wrapper (Chun Kuan Lee)
d59d48d utils: Convert fs error messages from multibyte to utf-8 (ken2812221)
9ef58cc Logging: use "fmterr" variable name for errors instead of general "e" that can be used by any other function. (furszy)
dd94241 utils: Use _wfopen and _wreopen on Windows (Chun Kuan Lee)
3993641 add unicode compatible file_lock for Windows (Chun Kuan Lee)
48349f8 Provide relevant error message if datadir is not writable. (murrayn)

Pull request description:

  As the software is currently using the ANSI encoding on Windows, the user's language settings could affect the proper functioning of the node/wallet, to the point of not be able to open some non-ASCII name files and directories.

  This solves the Windows encoding issues, completing the entire bitcoin#13869 work path (and some other required backports). Enabling for example users that use non-english characters in directories and file names to be accepted.

  Backported PRs:
  * bitcoin#12422.
  * bitcoin#12630.
  * bitcoin#13862.
  * bitcoin#13866.
  * bitcoin#13877.
  * bitcoin#13878.
  * bitcoin#13883.
  * bitcoin#13884.
  * bitcoin#13886.
  * bitcoin#13888.
  * bitcoin#14192.
  * bitcoin#13734.
  * bitcoin#14426.

  This is built on top of other two PRs that i have open #2423 and #2369.
  Solves old issues #940 and #2163.

  TODO:
  * Backport `assert_start_raises_init_error` and `ErrorMatch` in TestNode` (bitcoin#12718)

ACKs for top commit:
  Fuzzbawls:
    ACK 63e0be6
  random-zebra:
    ACK 63e0be6 and merging...

Tree-SHA512: cb1f7c23abb5b7b3af50bba18652cc2cad93fd7c2fca9c16ffd3fee34c4c152a3b666dfa87fe6b44c430064dcdee4367144dcb4a41203c91b0173b805bdb3d7d
@furszy
Copy link

furszy commented Aug 22, 2021

Solved, closing.

@furszy furszy closed this as completed Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Issues/problems specifically related to Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants