Best way to copy files under different OS? and clipboard??? lazarus / 8-Other ---------------------------------------------------------------------- Anonymous · 2005-12-23 16:16 Hi there, I created a small app. and I'm stuck at the following point :  The app needs to copy a folder with approx. 20 images to a folder which will be directly under the file created by the app (a web page). It's supposed to run on Win32, Linux and maybe MacOS. I would like to know what would be the best way for me to copy these files. I looked around but found mostly win32 specific code. Any advice would be greatly appreciated... Another point that annoys me : I want to have a clipboard that can copy text to various TEdits. I found online  WM_CUT WM_COPY and so on but they also seem to be win32 specific. Is there an equivalent to WM_CUT on Linux??? Thanks for any help (I'm a beginner so please be patient ---------------------------------------------------------------------- felipemdc · 2005-12-24 02:02 Ok, welcome! In the first case, copying files, you will be using a function from the Lazarus Component Library. To start with, add the unit "fileutil" without the quotes to your uses clause. There is a multiplatform (Windows, Linux, Mac OS X, FreeBSD and soon Pocket PC =P ) function for copying files. It is called CopyFile. Here you can see how this function is declared, and also other functions of the fileutil unit: http://www.freepascal.org/docs- html/lcl/fileutil/index-5.html About the Clipboard there are many Windows API functions implemented on a multiplatform way on the LCLIntf unit. Here is it's documentation: http://www.freepascal.org/docs- html/lcl/lclintf/index-5.html There are clipboard functions there. Take a look at them =P One extra information in case you don't know: The Free Pascal run-time library is very well documented, and the documentation is available here: http://www.freepascal.org/docs-html/rtl/index.html and Merry Christmas! ---------------------------------------------------------------------- Anonymous · 2005-12-24 11:42 Thanks a lot... I looked in the Wiki and faq under lazarus so I didn't come across this doc. Sorry about that. I'm going to try all that and see what i can come up with. One more stupid question : assuming I'm copying to a subfolder, how do I deal with the fact that the folder separator is not represented the same way under Unix and Win, I mean / and \ . If my folder is image do I have to make portions of code that are specific to both OS like CopyFile(start.png, images/start.png) and CopyFile(start.png, images\start.png) or is there a little trick? Thanks again for your help, Merry Xmas too and congrats for your site on braille, it's really great! ---------------------------------------------------------------------- Vincent Snijders · 2005-12-24 12:08 For your information: On the wiki, you can find a link to the LCL documentation: http://lazarus-ccr.sourceforge.net/docs/lcl/ Unfortunately google doesn't seem to index it. :-( ---------------------------------------------------------------------- felipemdc · 2005-12-24 14:21 QuoteOne more stupid question : assuming I'm copying to a subfolder, how do I deal with the fact that the folder separator is not represented the same way under Unix and Win, I mean / and \ . If my folder is image do I have to make portions of code that are specific to both OS like CopyFile(start.png, images/start.png) and CopyFile(start.png, images\start.png) or is there a little trick? Yes, there is a constant called DirectorySeparator. it is declared on the system unit and stores the path demiliter of the current operating system. There is another one, with the same value, called PathDelim provided on the SysUtils unit for Delphi compatibility. Just use something like: 'images' + DirectorySeparator + 'start.png' QuoteThanks again for your help, Merry Xmas too and congrats for your site on braille, it's really great! You're welcome ^^ ---------------------------------------------------------------------- Anonymous · 2005-12-25 09:26 All went file with CopyFile and DirectorySeparator but I'm still stuck with the clipboard issue. On Delphi, I simply had WM_COPY, WM_CUT and WM_PASTE for each procedure. I looked at the doc on the lcl but don't really get how I can implement it in my app. I need to be able to copy form different TextEdits to other TextEdits on different OS. Since there are a bunch of them, I would like to create 3 procedures (cut,copy and paste) that would apply to all of them. Any hint, link or example would be greatly appreciated. This is the last thing I need to release this app so I won't bug you after that with my stupid questions Thanks again for your help ---------------------------------------------------------------------- Marc · 2005-12-27 10:42 You mean that you send a WM_COPY to a control to put its contents on the clipboard ? Maybe you want to use TClipboard Code: [Select]uses   clipbrd; begin   clipboard.AsText := 'Some text'; end. ---------------------------------------------------------------------- Anonymous · 2005-12-29 21:05 Thanks but it's still a bit obscure to me... How do I send the content of what the user has selected to the clipboard, cut to it, paste from it from different edits in my unit? I mean is there some piece of code that could emulate what I had under Delphi : WM_COPY, WM_CUT and WM_PASTE would allow me to cut paste and copy and each procedure was a line long. I mean I guess I could do  Memo1.CutToClipboard; for each object but that would be very long... I looked at http://lazarus- ccr.sourceforge.net/docs/lcl/clipbrd/index.html but did not find how to implement it so that I achieve my goal... Sorry to bug you again with that...