[comp.sys.ibm.pc.programmer] How to rename directories and computer info

grandin@boulder.Colorado.EDU (Keith T. Grandin) (04/12/90)

	I have two programming questions :

	1 - Is there a way to do a real move of files?  I would like to
be able to move both files and directories, but Turboc's rename() function
and DOS function 86 (INT 33, _AH = 56H) do not support directory
moves (i.e. changing a directories name to a new path like moving
c:\tmp\norton to c:\norton).

	2 - How can a program find out what kind of processor and how
much memory is in the machine it is run on.  I would like to be able 
to write an "intelligent" program which could use extended memory 
if the correct processor and memory are availible.

	I would prefer responses to be in C (TurboC 2.0) but both
assembly (MASM 5.0) and pascal (Turbo Pascal 5.5) are fine.

Thanks in advance,

	Keith Grandin
	grandin@tramp.colorado.edu
	grandin%tramp@boulder.colorado.edu

wilber@sal-sun31.usc.edu (John Wilber) (04/13/90)

In article <19580@boulder.Colorado.EDU> grandin@tramp.Colorado.EDU (Keith Grandin) writes:

>	1 - Is there a way to do a real move of files?  I would like to

With one function call, I don't think so, but you should be able to copy
the file to the destination with a temporary name, delete the old file,
and then rename the new one with the filename from the old one.  You
should be able to do all of this, including assigning the temporary name
(if I'm correct) with INT 21 BIOS calls.

>	2 - How can a program find out what kind of processor and how

Gee, can't help you much here.  Looking at some Intel hardware manuals
might help you on this one.

>	Keith Grandin

/**********************************************************************\
* John J. Wilber        * Socialism and communism are for those people *
* wilber@nunki.usc.edu  * who feel they can't make it in a freely      *
* student, partier, and * competitive society.                         *
* fun-loving guy.       *                                              *
\**********************************************************************/

bakke@plains.UUCP (Jeffrey P. Bakke) (04/13/90)

>In article <19580@boulder.Colorado.EDU> grandin@tramp.Colorado.EDU (Keith Grandin) writes:
Stuff...
>
>>      2 - How can a program find out what kind of processor and how
>

You might want to download and check out the sources for fractint 12.0
(or any of the few previous versions).  They have source code for
determining what type of CPU and FPU you're using.  They use this to
determine which instruction set to use for floating point math...

Jeff Bakke
bakke@plains.NoDak.edu

elmo@image.soe.clarkson.edu (Paul B. Davidson,ERCTERM,2682292,2862026) (04/13/90)

From article <9065@chaph.usc.edu>, by wilber@sal-sun31.usc.edu (John Wilber):
> In article <19580@boulder.Colorado.EDU> grandin@tramp.Colorado.EDU (Keith Grandin) writes:
> 
>>	1 - Is there a way to do a real move of files?  I would like to
> 
> With one function call, I don't think so, but you should be able to copy
> the file to the destination with a temporary name, delete the old file,
> and then rename the new one with the filename from the old one.  You
> should be able to do all of this, including assigning the temporary name
> (if I'm correct) with INT 21 BIOS calls.
>

Forgive my stupidity if this won't work exactly, but how about simply
playing with the directory entry so that it appears in a different
location? That way, you don't have to worry about not having enough
space to copy and delete...

Of course, if you wanna move between disks, you're gonna have to move
and copy.... but you already knew *that*. :-)


-Paul B. Davidson, (elmo@sun.soe.clarkson.edu)

bobmon@iuvax.cs.indiana.edu (RAMontante) (04/13/90)

- <19580@boulder.Colorado.EDU> grandin@tramp.Colorado.EDU (Keith Grandin):
->	1 - Is there a way to do a real move of files?  I would like to
 
-<9065@chaph.usc.edu>, by wilber@sal-sun31.usc.edu (John Wilber):
- With one function call, I don't think so, but you should be able to copy
- the file to the destination with a temporary name, delete the old file,
- and then rename the new one with the filename from the old one.  You
- should be able to do all of this, including assigning the temporary name
- (if I'm correct) with INT 21 BIOS calls.

Eeek.  Check Interrupt 0x21, function 0x56, "rename file".  It does
precisely what you want, namely it creates a new directory entry (in the
desired subdirectory) and removes the old entry, without touching the
file itself.  The MSDOS "RENAME" command doesn't make use of this, but
various freely-available programs (often called "mv") do.  Turbo C's
rename() function makes use of this system call.

Naturally it can't work across devices.

frisk@rhi.hi.is (Fridrik Skulason) (04/13/90)

In article <9065@chaph.usc.edu> wilber@sal-sun31.usc.edu (John Wilber) writes:
>In article <19580@boulder.Colorado.EDU> grandin@tramp.Colorado.EDU (Keith Grandin) writes:
>
>>	1 - Is there a way to do a real move of files?  I would like to
>
>With one function call, I don't think so,

It is possible. INT 21H, function 56H will allow you to move a file, provided
the disks are the same.  It is just the fault of COMMAND.COM that you cannot
do this very easily.  I once wrote a tiny utility (in assembly) that would do
just this:

	MV /SUBDIR1/*.C /SUBDIR2/*.OLD

If anybody is interested just send me a note and I'll send you a copy.
>
>>	2 - How can a program find out what kind of processor and how
>

There was a program posted several months ago that did just this - I am not
sure if it could distinguish a 8088 from 8086, though.  I lost my copy, but
somebody must have it.
-- 
Fridrik Skulason      University of Iceland  |       
Technical Editor of the Virus Bulletin (UK)  |  Reserved for future expansion
E-Mail: frisk@rhi.hi.is    Fax: 354-1-28801  |