file.copyTo() ajoute le symbole interdit ':'

Bonjour,

le code suivant, très similaire à celui de la doc ne fonctionne pas

$myFile:=Folder($codeMirror).file("4d_source.js")
$myFile:=$myFile.copyTo(Folder($codeMirror);"4d.js";fk overwrite)

quand j’execute le code, j’ai l’erreur suivant sur le nom du fichier :
Capture d’écran 2020-06-30 à 11.54.15

un “:” s’est inséré.

PS: vraiment ch… ces émoticones automatiques :hot_face:

Comme je vois “synology” dans ton chemin et vu ce qui est constaté ici, je me demande si tu ne perds pas ton temps. Une réponse de 4D serait appréciée, je trouverais cavalier qu’il faille passer par le dépôt de bug pour apprendre que c’est standard behavior ou in progress.

Ca je suis bien d’accord !

1 Like

Bonjour Arnaud,

Oui effectivement, il y a le mot synology, mais c’est un dossier partagé, un peu comme le fait Dropbox. Tu as une copie du répertoire sur ton disque local qui est ‘synchronisé’ ou non automatiquement. Cela me permet de synchronisé plus facilement mes dev entre mes machines en fonction de là où je suis et de ce que j’ai sous la main.
Ce qui me chiffone, c’est ce ‘:’ qui apparait comme par enchantement.

J’avais vu la discussion avec Bernard qui, à la différence de mon cas, souhaite/souhaitait travailler directement sur le disque du Syno.

Je confirme.

Bon, le dossier Synology est hors de cause, y’a qu’à voir ci-dessous :

D’ailleurs, le problème est le même que l’on soit sur la v18R3 ou v18 LTS

I suspect $codeMirror is a system path.

Can you change it to

$myFile:=Folder($codeMirror;fk platform path).file("4d_source.js")

?

Hi,

Unfortunally, that changed nothing. Same error:

$myFile (‘4d_source.js’) is correctly defined (property ‘isFile’ is set at True)

I still got the error ‘File doesn’t exist’ during execution.

It still looks like the 2 types of paths are mixed in the code.

Get 4D folder returns SYSTEM. but you seem to be using slashes (POSIX) to process it. Also, you did not add fk platform path in line 46.

If you want to use POSIX consistently, it might help to remove Get 4D Folder in this code snippet. If you decide to do so, you will have to remove fk platform path.

Something like

$compilePath_s:=Folder("/PACKAGE/")

1 Like

Sorry,

same issue :

Ah oui alors !

I wish you posted the code, not a screenshot…I had to copy everything from the photo.

In your previous post you said

(property ‘isFile’ is set at True)

but the key is “exists”.

also I did not fully understand that you were using Replace string to convert separators. Normally, that is not necessary.

Could you try this:

C_OBJECT($myFile;$copy)

$app:="QS_ToolBox"

C_OBJECT($sourceFolder)
$sourceFolder:=Folder(Get 4D folder(Database folder);fk platform path)
$sourceFolder:=$sourceFolder.parent.folder($sourceFolder.name)  //remove .4dbase

If (False)
	$sourceFolder:=Folder("/PACKAGE/")  //same thing, smarter
End if 

$compileFolder:=$sourceFolder\
.folder($app+"_build")\
.folder("Base de données compilée")\
.folder($app+".4dbase")

$codeMirrorFolder:=$sourceFolder\
.folder($app+"_build")\
.folder("Base de données compilée")\
.folder($app+".4dbase")\
.folder("Resources")\
.folder("codemirror")\
.folder("mode")\
.folder("4d")

$myFile:=$codeMirrorFolder.file("4d_source.js")

If ($myFile.exists)
	
	$copy:=$myFile.copyTo($codeMirrorFolder;"4d.js";fk overwrite)
	
End if 

Hi Patrick

i must study the example from Myako later.

Here only my any wild example which i tested successfully in v18R3:

C_OBJECT($source;$copy)
$source:=Folder(fk database folder).file("test.html")
$copy:=$source.copyTo(Folder(fk database folder);"test2.html";fk overwrite)

I beg your pardon :lying_face:

I copied the code below and I got errors 59, then 54 (arguments are incompatible):


I also did the test with the constant, same.

I do not understand why? I’m completly lost with these new File & Folder commands. Seems to be powerfull, but, so strange.

Hi Lutz

It seems working well inside with constant predefined. I wasn’t wondering that was so ‘complicated’ to replace a file that you know very well with these new commands.
May I miss something, but I’m not able to figure out what.

What is the difference?

Get 4D folder(Database folder)
Folder(fk database folder)

i see only this diffence in my and our syntax, but i did not know what makes this maybe different?

I would say:
with the first syntax, you get a text information, with the second, an object

why my copyTo() example do not throw any error?

That is a good question, or why mine returns some?

For me, the biggest difference is whether the code works in a component or not.

Folder(fk database folder) 

syntax (fk constant) is always local to the project. No * support.

Folder(Get 4D folder(Database folder;*);fk platform path) 

works from inside a component to reference the host.

1 Like

What happens when you change only the one line in Miyako’s Code:

C_OBJECT($sourceFolder)
$sourceFolder:=Folder(Get 4D folder(Database folder);fk platform path)
C_OBJECT($sourceFolder)
$sourceFolder:=Folder(fk database folder)