Hello

I would like to know, programmatically, if the the directory created
when a tarball is decompressed exists or not. The tarball is in this
directory:

D:/Documents/msys2/opt/ewpi_test/share/ewpi/packages/foobar

So I want to execute with system() :

cd D:/Documents/msys2/opt/ewpi_test/share/ewpi/packages/foobar &&
dir_name=`tar tzf foobar.tar.gz | head -1 | cut -f1 -d"/"` && cd
$dir_name

If dir_name does not exists, cd will throw an error. I can use also a
test. The problem is not there anyway : when executed with system(),
dir_name is not known.

As there are problems, i first tried this test : using cygpath and
storing the result in a variable, then display this variable.
 :
1) Directly in MSYS2 :

cygpath -u D:/Documents/msys2/opt/ewpi_test

returns of course :

/opt/ewpi_test

2) With this code :

  char *cmd = "prefix=`cygpath -u D:/Documents/msys2/opt/ewpi_test` &&
echo $prefix";
  printf("%d\n", system(cmd));

I have this message (in french) :

'prefix' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.

Which can be translated as

'prefix' is not an internal command, or an external command, or a
executable program, or a command file

3) With this code (I execute the command with bash) :

  char *cmd = "/bin/bash prefix=`cygpath -u
D:/Documents/msys2/opt/ewpi_test` && echo $prefix";
  printf("%d\n", system(cmd));

I have this message (in french) :

Le chemin d'accès spécifié est introuvable.

which can be translated as

The specified access path can not be found

Does someone know how I can make the tests 2) a,d 3) as expected
(display the value /opt/ewpi_test like in 1) ?

thank you

Vincent Torri


_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to