Project

General

Profile

Bug #118

unistd and call to access in Main.C

Added by John Abbott about 12 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Portability
Target version:
-
Start date:
03 Apr 2012
Due date:
% Done:

100%

Estimated time:
8.00 h
Spent time:

Description

Replace call to access in Main.C (about line 192) by calls to BOOST filesystem fns such as exists and is_regular_file or is_directory. We should probably also use values of type path.


Related issues

Related to CoCoA - Bug #53: MSVC10 compilationClosed2011-12-07

History

#1 Updated by John Abbott about 12 years ago

Discovering that BOOST seems to offer a ready-made solution, and that access is old-style C-library.

#2 Updated by John Abbott about 12 years ago

The purpose of the original code is unclear -- indeed it looks implausible/wrong.

  if (defaultPackageDir && access(packageDir.c_str(), F_OK))
    packageDir = ".";

Why test the existence of the file located in packageDir and then change the value of that same variable?
JAA will ask Giovanni (the original author) for help/guidance.

#3 Updated by John Abbott about 12 years ago

To answer the question "why...?" in the last update: the fn access returns 0 if the file exists, and -1 if it does not (the opposite of what I expected).

I have replaced the relevant line of code with calls to fns from the BOOST sublibrary filesystem. This makes the source far more readable, and presumably portable too -- at the cost of requiring a (more) complete installation of BOOST on the computer you want to compile on.

JAA does not see the point of permitting CoCoA-5 to be run without its standard libraries. The same end effect could easily be achieved by creating an empty directory somewhere, and then starting CoCoA with the --package-dir option saying to look in that empty directory for packages.

It seems better to issue an error if one has a "broken" CoCoA installation which is missing the standard package directory -- this is a design issue, and must be discussed with Anna.

#4 Updated by John Abbott about 12 years ago

  • Status changed from New to Resolved

#5 Updated by John Abbott about 12 years ago

  • Priority changed from Normal to High

Increased priority to "high".

Waiting for Anna's return to discuss the correctness/usefulness of allowing CoCoA-5 to run if there's a problem with the default package directory.

I do hope we can "close" this issue shortly.

#6 Updated by Anna Maria Bigatti almost 12 years ago

  • Category set to Portability

#7 Updated by John Abbott almost 12 years ago

Anna could you reply to my question in post 5?

I think it should be an error to start CoCoA without the packages. JAA thinks that if you really want to do this, you must use a command line flag (e.g. --without-packages).

Can you think of a scenario when it might actually be useful to run CoCoA without the packages?

Note to JAA: regardless of Anna's answer, the code must always check for the presence of the packages (i.e. it will always be dependent on the BOOST fns I have used).

#8 Updated by Anna Maria Bigatti almost 12 years ago

John Abbott wrote:

Waiting for Anna's return to discuss the correctness/usefulness of allowing CoCoA-5 to run if there's a problem with the default package directory.

I agree it is very likely an error that one should start CoCoA-5 without the packages, but CoCoA-5 can do a lot of things (eventually, in our dreams, everything) without the packages.
So I think it should be allowed to use CoCoA without the packages, maybe with a BIG WARNING banner.

#9 Updated by John Abbott almost 12 years ago

Anna's point about almost everything (eventually) being built-in is valid; I was forgetting that. Also my "note" in post 7 points out that there is no source code simplification in giving an error rather than a warning.

So, let's give a highly visible warning (together with an indication of where CoCoA expected to find its packages).

JAA reiterates that he thinks the use of the BOOST fns is the neatest portable solution (too bad about needing a more complete BOOST installation).

#10 Updated by John Abbott almost 12 years ago

  • Assignee set to John Abbott
  • % Done changed from 0 to 90

I have improved the warning message when the default package directory is not accessible (for text UI, and GUI).

The warning is printed on cout (rather than cerr).

The name of the missing directory is printed in the text UI (but not in the GUI).

Waiting for confirmation from Anna that my solution is acceptable (or else give me constructive criticism).

#11 Updated by John Abbott about 11 years ago

  • Status changed from Resolved to Feedback

Can we regard this as closed now?

#12 Updated by John Abbott about 10 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

No problems for over a year --> closing!

Also available in: Atom PDF