home *** CD-ROM | disk | FTP | other *** search
- /*=============================================================================
-
- The INSTALL program source code, object code, sample script files,
- executable program, and documentation are subject to copyright
- protection under the laws of the United States and other countries.
-
- This software is licensed, not sold, and may only be redistributed
- in executable format and only in accordance with the provisions of
- the INSTALL Source Code License Agreement.
-
- INSTALL is Copyright(C) 1987-1990 by Knowledge Dynamics Corp
- Highway Contract 4 Box 185-H, Canyon Lake, TX (USA) 78133-3508
- 512-964-3994 (Voice) 512-964-3958 (24-hr FAX)
-
- All rights reserved worldwide.
-
- ===============================================================================
-
- FILENAME:
- install.c
-
- AUTHOR:
- eric jon heflin
-
- PUBLIC FUNCTIONS:
- install() - master file copy function
- disk_avail() - get free disk space after adding overwritten file space
-
- LOCAL FUNCTIONS:
- none
-
- DESCRIPTION:
- This file first checks to see if there is enough available space on the
- target drive and then either copies the specified files, or if there is
- insufficient space, it notify the user. If the target drive is
- non-removable, then the end-user is told to install onto another drive,
- or to free up ##### bytes of disk space. If the target drive is a
- removable drive, then the end-user is given the additional option of
- replacing the output disk.
-
- REVISION HISTORY:
- DATE: AUTHOR: DESCRIPTION OF CHANGES:
- 891030 allyn jordan Beginning of detailed documentation.
- 891116 ejh Added code to handle ambiguous filename specifiers
- for library files.
- 900102 ejh Cosmetic changes.
-
- ==============================================================================*/
-
- #include "install.h"
- #include <string.h>
- #include <assert.h>
-
- void install(project)
- project_t *project;
- { /* install */
- disk_t *disk; /* input disk pointer */
- file_t *file;
- file_t *f;
- unsigned long needed, have;
-
- /*
- * Algorithm: Check for adequate free disk space on the output drive
- * using a lazy algorithm which only checks for space before writing
- * the first output file to that disk.
- *
- * This is necessary since the input drive and output drive may be the
- * same, and future versions of INSTALL will probably support an
- * unlimited number of output drives.
- */
-
- /*
- * Loop to determine if adequate free space exists on the output drive.
- * This loop is only executed for non-removable disks.
- */
- if (!project->removable)
- {
- have = disk_avail(project->out_drive, project->subdir, project->disk, project->disk->file);
- needed = project->requirement;
-
- /* see if adequate space was found */
- if (needed > have)
- {
- wputs(message_w, "The disk in output drive %c: does not have enough space to install", project->out_drive);
- wputs(message_w, "%s.", project->name);
- if (project->removable)
- {
- wputs(message_w, NULL);
- wputs(message_w, "Please place a disk with at least %lu bytes free in drive %c:", project->requirement, project->out_drive);
- wputs(message_w, "or press [Esc] to abort ...");
- put_message(message_w);
- project->out_free = disk_free(project->out_drive);
- project->out_size = disk_size(project->out_drive);
- } /* removable */
- else
- { /* fixed */
- wputs(message_w, NULL);
- wputs(message_w, "Since the output disk is non-removable, in order to install");
- wputs(message_w, "this product you will have to 1) free up %lu bytes of space", needed - have);
- wputs(message_w, "on this disk, or 2) install onto another drive.");
- put_message(message_w);
- bye();
- }
- /*
- wputs(error_w, "The minimum required free space is: %lu bytes\n", needed);
- wputs(error_w, "Drive %c: only has %lu bytes free\n", project->out_drive, have);
- wputs(error_w, NULL);
- wputs(error_w, "You should either free up some disk space, or");
- wputs(error_w, "only install part of this product.");
- put_error(error_w);
- */
- } /* if we don't have enough disk space */
- } /* if outdrive is fixed */
-
- /* for loop to copy all distribution disks */
- for (disk = project->disk; disk != NULL; disk = disk->next)
- {
- /* for loop to copy all files on one distribution disk */
- for (file = disk->file; file != NULL; file = file->next)
- {
- if (file->type == PARENT && file->sub != NULL)
- {
- /* this file is a library file */
- /* first, open lib and read all header info */
- copy_file(project, disk, file, &have);
- /* for loop to copy each each library file */
- for (f = file->sub; f != NULL; f = f->next)
- copy_file(project, disk, f, &have);
- continue;
- }
- else if (file->type != PARENT)
- copy_file(project, disk, file, &have);
- } /* copy file loop */
- } /* copy disk loop */
- } /* install() proper */
-
-
- /* determine logically available space on disk */
-
- unsigned long disk_avail(byte drive, byte *dir, disk_t * disk, file_t * file)
- { /* disk_avail */
- unsigned long have = 0L;
- file_t *f, *temp_f;
- byte temp_n[100];
- disk_t *d;
-
- if (disk == NULL)
- return 0L;
-
- have = disk_free(drive);
-
- /*
- * process each disk, starting with file f on disk d.
- */
- for (d = disk, f = file; d != NULL; d = d->next)
- {
- f = d->file;
- /*
- * process each file on disk d.
- */
- for (temp_f = f; temp_f != NULL; temp_f = temp_f->next)
- {
- if (temp_f->type == PARENT)
- {
- /* this is a library */
- for (f = temp_f->sub; f != NULL; f = f->next)
- {
- if (!f->abs)
- sprintf(temp_n, "%c:%s%s", drive, dir, f->out_fname);
- else
- strcpy(temp_n, f->out_fname);
- /* if file exists, add its size to avail disk space */
- have += (ulong)findsize(temp_n);
- }
- }
- else
- {
- if (!temp_f->abs)
- sprintf(temp_n, "%c:%s%s", drive, dir, temp_f->out_fname);
- else
- strcpy(temp_n, temp_f->out_fname);
- /* if file exists, add its size to avail disk space */
- have += (ulong)findsize(temp_n);
- }
- } /* for all output files */
- } /* for loop to check for disk space */
- return have;
- } /* disk_avail */
-
-
- /* end-of-file */
-