Exemplo n.º 1
0
        /// <summary>
        /// Gets the next cluster
        /// </summary>
        /// <returns></returns>
        protected bool NextClusterExpand()
        {
            Flush();

            uint newcluster = 0;

            if (currentCluster == 0)
            {
                if (startCluster == 0)
                {
                    uint newCluster = fs.AllocateFirstCluster(directorySector, directorySectorIndex);

                    if (newCluster == 0)
                    {
                        return(false);
                    }

                    startCluster   = newCluster;
                    currentCluster = newCluster;
                    dirty          = true;

                    // Clear cluster
                    for (int i = 0; i < clusterSize; i++)
                    {
                        data[i] = 0;
                    }

                    return(true);
                }

                newcluster = startCluster;
            }
            else
            {
                newcluster = fs.GetNextCluster(currentCluster);

                if (newcluster == 0)
                {
                    uint newCluster = fs.AddCluster(currentCluster);

                    if (newCluster == 0)
                    {
                        return(false);
                    }

                    currentCluster = newCluster;
                    dirty          = true;

                    // Clear cluster
                    for (int i = 0; i < clusterSize; i++)
                    {
                        data[i] = 0;
                    }

                    return(true);
                }
            }

            ReadCluster(newcluster);

            return(true);
        }