Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libgis: Distinguish dirs and objects in dir creation (#1681)
The G_make_mapset_element() function is used in several places to create nested directories such as grid3/some_raster3d_name for particular maps/objects. However, the original purpose of G_make_mapset_element() seems to be creating directories (such as fcell, vector) for these objects (objects such as elevation or bridges). This change introduces new API functions which make distinction between these scenarios. One function is for what most of the original API calls element that is the directory for objects of the same type. The other is for the objects themselves. The three new functions replace two existing ones. Two replace G_make_mapset_element() covering the two cases and one replaces G_make_mapset_element_tmp() covering only the common directory case because there is no direct use of this functionality in the current code. In the new API, dir_object is for the vector/name case and object_group for the vector and fcell cases. The vector/name case is a single function call with more parameters rather than two function calls and replaces the use of %s/%s syntax which is what was used before. Distinguishing the two scenarios allows the code to handle differently a race condition during creation when another process creates the same directory between the failed access call and mkdir call. In case of directory such as fcell or vector, all we asked for was that the directory exists at the end of the function call which will be fulfilled even when mkdir happened in another process. Same race condition for directories such as cell_misc/raster_map_name or vector/vector_map_name is actual problem and reporting it sooner rather than later is advantageous in detecting the issue (assuming that the issue is two processes are trying to create map of the same name). However, this is not the new behavior for some vector files where %s/%s syntax is still used to create the parent directories without making any distinctions about the purpose of the directory. This is the behavior which the code had before 3c37460 which was intended to imporve error message, but it changed also the the on-creation-race behavior. The underlying issue seems to be, at least partially, the unclear naming. Element sometimes refers to the particular file such as fcell/raster_map_name, but in the G_make functions, it refers to the directory of these files such as fcell. This new API does not use any great names, but the idea is to refer to element group directories (such as cell) and specific element files or directories (raster map piece, sub-directory for a specific vector map). The hope is that in the new API, words directory, object, and type are used in somewhat common way. Creation of misc elements (cell_misc and group) is now the two-phase creation of an object which is a dir. Function is internal (double underscore after G), used consistently, and documented such that element is the name of the concrete object, so keeping the name as is. The documentation of functions is based on the current usage and new names although the terminology is not a new official terminology.
- Loading branch information
1 parent
4daf102
commit 23a8e6d
Showing
13 changed files
with
153 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters