cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/main/java/org/cloudbus/cloudsim/resources/HarddriveStorage.java
@Override
    public double addFile(final File file) {
        double result = 0.0;
        if (!File.isValid(file)) {
            Log.printConcatLine(name, ".addFile(): Invalid file ", file);
            return result;
        }

       // check the capacity
        if (!storage.isResourceAmountAvailable((long)file.getSize())) {
            Log.printConcatLine(name, ".addFile(): Warning - not enough space to store ", file.getName());
            return result;
        }

        // check if the same file name is alredy taken
        if (!contains(file.getName())) {
            final double seekTime = getSeekTime(file.getSize());
            final double transferTime = getTransferTime(file.getSize());

            fileList.add(file);               // add the file into the HD
            fileNameList.add(file.getName());     // add the name to the name list
            storage.allocateResource((long)file.getSize());    // increment the current HD space
            result = seekTime + transferTime;  // add total time
            file.setTransactionTime(result);
        }
        return result;
    }
/**
     * {@inheritDoc}
     *
     * <p/>First, the method checks if there is enough space on the storage,
     * then it checks if the file with the same name is already taken to avoid duplicate filenames.
     *
     * @param file {@inheritDoc}
     * @return {@inheritDoc}
     */
First, the method checks if there is enough space on the storage,
then it checks if the file with the same name is already taken to avoid duplicate filenames.

@param file
@return
First the method checks if there is enough space on the storage then it checks if the file with the same name is already taken to avoid duplicate filenames . @param file @return
@Override
    public double addFile(final File file) {
        double result = 0.0;
        if (!File.isValid(file)) {
            Log.printConcatLine(name, ".addFile(): Invalid file ", file);
            return result;
        }
        if (!storage.isResourceAmountAvailable((long)file.getSize())) {
            Log.printConcatLine(name, ".addFile(): Warning - not enough space to store ", file.getName());
            return result;
        }
        if (!contains(file.getName())) {
            final double seekTime = getSeekTime(file.getSize());
            final double transferTime = getTransferTime(file.getSize());
            fileList.add(file);               
            fileNameList.add(file.getName());     
            storage.allocateResource((long)file.getSize());    
            result = seekTime + transferTime;  
            file.setTransactionTime(result);
        }
        return result;
    }
@ Override public double addFile ( final File file ) { double result = 0.0 ; if ( ! File . isValid ( file ) ) { Log . printConcatLine ( name , ".addFile(): Invalid file " , file ) ; return result ; } if ( ! storage . isResourceAmountAvailable ( ( long ) file . getSize ( ) ) ) { Log . printConcatLine ( name , ".addFile(): Warning - not enough space to store " , file . getName ( ) ) ; return result ; } if ( ! contains ( file . getName ( ) ) ) { final double seekTime = getSeekTime ( file . getSize ( ) ) ; final double transferTime = getTransferTime ( file . getSize ( ) ) ; fileList . add ( file ) ; fileNameList . add ( file . getName ( ) ) ; storage . allocateResource ( ( long ) file . getSize ( ) ) ; result = seekTime + transferTime ; file . setTransactionTime ( result ) ; } return result ; }
{@inheritDoc}
 <p/>First, the method checks if there is enough space on the storage,
 then it checks if the file with the same name is already taken to avoid duplicate filenames.
{ @inheritDoc } <p / > First the method checks if there is enough space on the storage then it checks if the file with the same name is already taken to avoid duplicate filenames .
// check the capacity // check if the same file name is alredy taken // add the file into the HD // add the name to the name list // increment the current HD space // add total time