Page 1 of 1

copy, move in command promp

Posted: Thu Dec 22, 2011 10:41 pm
by linuxfreak
Hi all...
I have been following this os dev tutorials for quite a while and everything is going very nicely - i have a command line interface a nice bootloader and a basic graphics driver(self written) that allows me to display pictures(mainly bmp's) for a user interface. Im still working on the mouse drivers(they seem to be problematic). The gui features some background wallpaper thingies and moveable and resizeable windows with a basic title bar. The gui is based on the command line(like in windows 1, 2, and 3).
The main question is - how do i implement a basic file copy, paste and move function in the command promp? This means that i probably have to write a clipboard function in kernel as well.

I have found some info on this by googeling and on the microsof developer website but this is all for windows/linux. and everything i found is based on files inside those os's.

Can anybody help me on this matter?

All comments are welcomed...

Re: copy, move in command promp

Posted: Thu Dec 22, 2011 10:45 pm
by linuxfreak
Sorry about the bad spelling of 'prompt' - it seams that i forgot about them - " t's "

Re: copy, move in command promp

Posted: Mon Dec 26, 2011 4:11 pm
by Andyhhp
First of all, you need a clipboard. It doesn't nesseserally have to be in the kernel, but it does need to be system wide accessable.

You need to have an API to read, write and clear the clipboard.

Then, your command prompt keystroke interpreter should recognise certain keystoke combinations and use your new API to access the clipboard.

~Andrew

Re: copy, move in command promp

Posted: Tue Dec 27, 2011 9:37 pm
by linuxfreak
Thank you for you straight answere...

ok then, i have created a function that accepts arguments (filenames and destination directories). Now what is involved in actually copying or moving the file(what i mean is, how do i actually code the copying and moving of files and folders in c++.
Yet another question is, what is a clipboard - i understand it as a piece of memory that holds the address of the file or folder and how it should be used(copied, moved, etc.) and the destination address. Please correct me if im wrong...

thank you so much for helping - not to mention the day after christmas...

Jean-Pierre:

Re: copy, move in command promp

Posted: Tue Dec 27, 2011 9:57 pm
by linuxfreak
Sorry need to clear this out...

The gui is not all that important at this moment, but rather the command prompt. So at this stage in time the os is mainly command prompt and can switch to 'user mode'(gui) via a command. I created a command that is something like "copy 'file.ext' 'A:\destination'. This doesn't need a clipboard does it? Thi clipboard is mainly used in the gui right? So for the time being lets just focus on the command prompt thing.

Thanx again...

Jean-Pierre:

Re: copy, move in command promp

Posted: Tue Dec 27, 2011 10:09 pm
by Andyhhp
Ah - I misread you question. You can ignore about clipboards for your purposes, although they most certainly are not just a gui concept.

a simple command line mv is trivial if you have a filesystem driver and some standard library functions for accessing the filesystem driver.

If you lack those, then you need to implement them before you can make command line utilities to do things.

~Andrew

Re: copy, move in command promp

Posted: Wed Dec 28, 2011 8:50 am
by linuxfreak
OK...

I am currently still using fat12 like sugested in these tutorials. I am going to implement fat32 soon-i just need to work out a few bugs. With the fat12 filesystem i can open and close files and some other basic functions. But i would like to know how i should copy and move files using c++.

Jean-Pierre

Re: copy, move in command promp

Posted: Wed Dec 28, 2011 10:02 pm
by Andyhhp
Copy and Move are very simple when thinking about what they are actually doing.

With copy, you want to duplicate the data into another file. So, your copy program needs to open 1 file for reading, and create a new file for writing. Then just loop reading data from 1 file and writing it to the other, preforably in 512 or 4K or bigger chunks.

Move is much more simple - all it needs to do is edit the filesystem metadata so the old file has a new name.

~Andrew

Re: copy, move in command promp

Posted: Thu Dec 29, 2011 7:11 am
by linuxfreak
:oops: Sorry im still an noob at C++ programming, I just started learning when i started with these tutorials.

I will look into getting some samples of how to do that. Thank you for all your help, i do appreciate it... By the looks of things i have to also implement a way to write to files. That shouldn't be too hard.

Jean-Pierre :P