Search code examples
cibm-midrangemkdirrpgle

Create a directory in IFS using mkdir procedure AS400/IBMi


I reached an issue this afternoon trying to create in RPGLE different directories in IFS using C procedures mkdir to do that. But when I'm testing if my new folder exists with worklnk command I have the following error CPFA0A9 like what my folder doesn't exist but I can add new files and folder using IFS tools.

Do you have any ideas ?

regards :)

fullpath = '//home/usr/' + %trim(£p1.pNomProduit);

  If (not Ctrl_Dossier(fullpath));
    // create folder
    // owner authority 448 + group authority 56 + other people 7 = 511
    result = mkdir(fullpath:S_IRWXU+S_IRWXG+S_IRWXO);

  else;
    result = rmdir(fullpath);
  ENDIF;                           

my mkdir procedure:

D mkdir           PR            10I 0 ExtProc('mkdir')
     D   path                          *   Value options(*string)
     D   mode                        10U 0 Value    

Solution

  • @player1st comment is correct, should be '/home/usr/' not '//home/usr/'

    Also what is the datatype for fullpath? Really should be varchar() but if fixed length, you'll want to include options(*TRIM) on the prototype. Otherwise, the directory name includes trailing spaces.

    D mkdir           PR            10I 0 ExtProc('mkdir')
    D   path                          *   Value options(*trim:*string)
    D   mode