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

linapple.conf created during the FIRST RUN of the program is blank #137

Open
nerun opened this issue May 27, 2020 · 3 comments
Open

linapple.conf created during the FIRST RUN of the program is blank #137

nerun opened this issue May 27, 2020 · 3 comments

Comments

@nerun
Copy link
Contributor

nerun commented May 27, 2020

I have noticed that the file ~.config/linapple/linapple.conf is created during the first run of the program. But it is a blank file!

It would not be better if the program copied the existing version in /usr/local/etc/linapple/linapple.conf instead?

Related source file: src/Applewin.cpp, line 973.

@nerun nerun changed the title linapple.conf linapple.conf created during the FIRST RUN of the program is blank Oct 5, 2021
@nerun
Copy link
Contributor Author

nerun commented Oct 5, 2021

POSSIBLE SOLUTION

src/Applewin.cpp, at top, add:

#include <fstream>

Now, around line 973:

  std::string userDir(home);
  mkdir(xdgConfigHome.c_str(), 0700);
  mkdir((xdgConfigHome + "/linapple").c_str(), 0700);
  registry = fopen((xdgConfigHome + "/linapple/linapple.conf").c_str(), "w+");
}

Change to:

  std::string userDir(home);
  mkdir(xdgConfigHome.c_str(), 0700);
  mkdir((xdgConfigHome + "/linapple").c_str(), 0700);
  
  // If there is a global install, copy default config file to user's config folder
  if ( "/usr/local/etc/linapple/linapple.conf" ) {
    std::ifstream ifs("/usr/local/etc/linapple/linapple.conf", std::ios::binary);
    std::ofstream ofs((xdgConfigHome + "/linapple/linapple.conf").c_str(), std::ios::binary);
    ofs << ifs.rdbuf();
    registry = fopen((xdgConfigHome + "/linapple/linapple.conf").c_str(), "r+");
  }
  else {
    registry = fopen((xdgConfigHome + "/linapple/linapple.conf").c_str(), "w+");
  }
}

It does works for me. I don't know if this is the proper way to do that.

I don't know how to use "XDG" stuff so i have used /usr/local/etc/linapple/linapple.conf.

It might be interesting to copy Master.dsk too:

# from:
/usr/local/share/linapple/Master.dsk
# to
~/.linapple/disks/

@nerun
Copy link
Contributor Author

nerun commented Oct 6, 2021

I have closed my PR because i think we should discuss this better. Anybody could help-me?

@walterg74
Copy link

Observed the same thing. "Solved" it by copying the file that gets installed to /usr/local/etc/linapple to ~/.config/linapple.

Not sure I understand why the install process copies the file to that location if it will not use it (plus of course why on run it's created blank).

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

No branches or pull requests

2 participants