nucm-logo

NUCM-2.0 Documentation
Interface: Collection: nc_remove


[Versioning | Collection | Query]

[nc_add | nc_remove | nc_rename | nc_replaceversion | nc_copy]

Signature

int  nc_remove(const char*  target,
               const char*  t_cwd,
               int  forced)

Functionality

Removes the artifact determined by the parameters target and t_cwd from the collection in the workspace. If the artifact has been opened, the artifact is removed from the workspace. If the artifact is a collection, its members are removed from the workspace as well. If the artifact is a collection and itself or one or more of its members is initiated, the remove does not succeed unless the remove is forced. A remove is forced if the value of the parameter forced is 1, a remove is not forced if the value of the parameter forced is 0. The collection from which the artifact is removed has to be initiated.

Return Values

0: everything went ok
-1: an error occurred

NdbErrno Codes

NdbOk :everything went ok
NdbUnknown:the path does not represent a NUCM artifact
NdbLonely : no collection present in the workspace from which the artifact can be removed
NdbNotInit: the collection from which to remove the artifact is not initiated
NdbInitiated: the artifact is a collection and itself or one or more of its members is initiated and the remove is not forced

Example

Assuming a repository is filled with projects, and in particular contains two projects "my_project" and "his_project" that both contain the artifacts ".login" and ".cshrc". Furthermore, a workspace has been created earlier in which "my_project" and its artifacts have been opened:
   /home/bigtime/andre/workspace/my_project/.login
					    .cshrc
To remove ".cshrc" from "my_project", the following code fragment can be used:
   #include "nc.h"
   
   nc_initiatechange("my_project",
		     "/home/bigtime/andre/workspace");
   nc_remove(".cshrc",
	     "/home/bigtime/andre/workspace/nucm_root",
	     "/home/bigtime/andre/workspace/nucm_root",
	     "");
   nc_commitchangeandreplace("my_project",
	                     "/home/bigtime/andre/workspace");
The workspace now looks as follows:
   /home/bigtime/andre/workspace/my_project/.login
The artifact ".cshrc" still exists in the repository at this point, as "his_project" still contains it. If we now want to remove all of "his_project", the following code fragment can be used:
   #include "nc.h"
   
   nc_open("//serl.cs.colorado.edu:1234/nucm_root",
	   "",
	   "/home/bigtime/andre/workspace",
	   "");
   nc_initiatechange("nucm_root",
		     "/home/bigtime/andre/workspace");
   nc_remove(".his_project",
	     "/home/bigtime/andre/workspace/nucm_root",
	     0);
   nc_commitchangeandreplace("nucm_root",
	                     "/home/bigtime/andre/workspace");
   nc_close("nucm_root",
	    "/home/bigtime/andre/workspace",
	    0);
Two things are noteworthy about this code fragment. Firstly, "his_project" did not need to have been opened to be removed from "nucm_root". Would it have been opened, it would have been removed from the workspace. Secondly, artifact ".cshrc" is not referenced by "my_project", and as "his_project" is removed from the repository and it contained the last reference to ".cshrc", ".cshrc" will be garbage collected.

[Top | Quick Index] [Concepts | Interface]

SERL <serl.cs.colorado.edu>