When a PC edits file, does it delete original file?












1















If code.txt (or whatever file) is edited and saved:



[Theory 1] The PC deletes code.txt completely and make new code.txt (edited version) from scratch.



[Theory 2] The PC edits part of hex of code.txt. So no delete happens.



Which theory do computers work?










share|improve this question







New contributor




Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    If code.txt (or whatever file) is edited and saved:



    [Theory 1] The PC deletes code.txt completely and make new code.txt (edited version) from scratch.



    [Theory 2] The PC edits part of hex of code.txt. So no delete happens.



    Which theory do computers work?










    share|improve this question







    New contributor




    Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      If code.txt (or whatever file) is edited and saved:



      [Theory 1] The PC deletes code.txt completely and make new code.txt (edited version) from scratch.



      [Theory 2] The PC edits part of hex of code.txt. So no delete happens.



      Which theory do computers work?










      share|improve this question







      New contributor




      Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      If code.txt (or whatever file) is edited and saved:



      [Theory 1] The PC deletes code.txt completely and make new code.txt (edited version) from scratch.



      [Theory 2] The PC edits part of hex of code.txt. So no delete happens.



      Which theory do computers work?







      editing






      share|improve this question







      New contributor




      Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 hour ago









      Chess ManChess Man

      161




      161




      New contributor




      Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Chess Man is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          5














          Could be either – it depends on the text editor that was used.



          The concept of a 'text file' isn't built into computers – each operating system may manage files differently, and each text editor may use those files differently.



          In practice, you'll find text editors which have both mechanisms. Simple editors such as Notepad usually just ask the OS to write directly into the original file, as that's easiest to implement – but risky if you lose power mid-write. So for reliability reasons, many editors deliberately save the updated data to a new file and delete the original.



          (I think in-place updates are more common among hex editors, where most edits don't insert/delete bytes but only change existing locations, so a full rewrite file is not needed.)



          There's even a third mode of operation – the editor might first make a backup copy of the old file, then directly write new data into the file.





          It also depends on the filesystem which keeps the file. With most traditional filesystems, if a program asks to write to an existing file, the filesystem will just overwrite old data in-place.



          However, some filesystems do work in "copy-on-write" mode, where any new data is always written to a different location, whether the program wants it or not. Again, this has the possible advantage of increased reliability because an interrupted change can be fully reverted.



          In some filesystems (such as Btrfs or ext4) this is an optional feature; in others (e.g. log-structured filesystems) it is part of the core design.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Chess Man is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397186%2fwhen-a-pc-edits-file-does-it-delete-original-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            Could be either – it depends on the text editor that was used.



            The concept of a 'text file' isn't built into computers – each operating system may manage files differently, and each text editor may use those files differently.



            In practice, you'll find text editors which have both mechanisms. Simple editors such as Notepad usually just ask the OS to write directly into the original file, as that's easiest to implement – but risky if you lose power mid-write. So for reliability reasons, many editors deliberately save the updated data to a new file and delete the original.



            (I think in-place updates are more common among hex editors, where most edits don't insert/delete bytes but only change existing locations, so a full rewrite file is not needed.)



            There's even a third mode of operation – the editor might first make a backup copy of the old file, then directly write new data into the file.





            It also depends on the filesystem which keeps the file. With most traditional filesystems, if a program asks to write to an existing file, the filesystem will just overwrite old data in-place.



            However, some filesystems do work in "copy-on-write" mode, where any new data is always written to a different location, whether the program wants it or not. Again, this has the possible advantage of increased reliability because an interrupted change can be fully reverted.



            In some filesystems (such as Btrfs or ext4) this is an optional feature; in others (e.g. log-structured filesystems) it is part of the core design.






            share|improve this answer




























              5














              Could be either – it depends on the text editor that was used.



              The concept of a 'text file' isn't built into computers – each operating system may manage files differently, and each text editor may use those files differently.



              In practice, you'll find text editors which have both mechanisms. Simple editors such as Notepad usually just ask the OS to write directly into the original file, as that's easiest to implement – but risky if you lose power mid-write. So for reliability reasons, many editors deliberately save the updated data to a new file and delete the original.



              (I think in-place updates are more common among hex editors, where most edits don't insert/delete bytes but only change existing locations, so a full rewrite file is not needed.)



              There's even a third mode of operation – the editor might first make a backup copy of the old file, then directly write new data into the file.





              It also depends on the filesystem which keeps the file. With most traditional filesystems, if a program asks to write to an existing file, the filesystem will just overwrite old data in-place.



              However, some filesystems do work in "copy-on-write" mode, where any new data is always written to a different location, whether the program wants it or not. Again, this has the possible advantage of increased reliability because an interrupted change can be fully reverted.



              In some filesystems (such as Btrfs or ext4) this is an optional feature; in others (e.g. log-structured filesystems) it is part of the core design.






              share|improve this answer


























                5












                5








                5







                Could be either – it depends on the text editor that was used.



                The concept of a 'text file' isn't built into computers – each operating system may manage files differently, and each text editor may use those files differently.



                In practice, you'll find text editors which have both mechanisms. Simple editors such as Notepad usually just ask the OS to write directly into the original file, as that's easiest to implement – but risky if you lose power mid-write. So for reliability reasons, many editors deliberately save the updated data to a new file and delete the original.



                (I think in-place updates are more common among hex editors, where most edits don't insert/delete bytes but only change existing locations, so a full rewrite file is not needed.)



                There's even a third mode of operation – the editor might first make a backup copy of the old file, then directly write new data into the file.





                It also depends on the filesystem which keeps the file. With most traditional filesystems, if a program asks to write to an existing file, the filesystem will just overwrite old data in-place.



                However, some filesystems do work in "copy-on-write" mode, where any new data is always written to a different location, whether the program wants it or not. Again, this has the possible advantage of increased reliability because an interrupted change can be fully reverted.



                In some filesystems (such as Btrfs or ext4) this is an optional feature; in others (e.g. log-structured filesystems) it is part of the core design.






                share|improve this answer













                Could be either – it depends on the text editor that was used.



                The concept of a 'text file' isn't built into computers – each operating system may manage files differently, and each text editor may use those files differently.



                In practice, you'll find text editors which have both mechanisms. Simple editors such as Notepad usually just ask the OS to write directly into the original file, as that's easiest to implement – but risky if you lose power mid-write. So for reliability reasons, many editors deliberately save the updated data to a new file and delete the original.



                (I think in-place updates are more common among hex editors, where most edits don't insert/delete bytes but only change existing locations, so a full rewrite file is not needed.)



                There's even a third mode of operation – the editor might first make a backup copy of the old file, then directly write new data into the file.





                It also depends on the filesystem which keeps the file. With most traditional filesystems, if a program asks to write to an existing file, the filesystem will just overwrite old data in-place.



                However, some filesystems do work in "copy-on-write" mode, where any new data is always written to a different location, whether the program wants it or not. Again, this has the possible advantage of increased reliability because an interrupted change can be fully reverted.



                In some filesystems (such as Btrfs or ext4) this is an optional feature; in others (e.g. log-structured filesystems) it is part of the core design.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                grawitygrawity

                234k36495551




                234k36495551






















                    Chess Man is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Chess Man is a new contributor. Be nice, and check out our Code of Conduct.













                    Chess Man is a new contributor. Be nice, and check out our Code of Conduct.












                    Chess Man is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397186%2fwhen-a-pc-edits-file-does-it-delete-original-file%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to label and detect the document text images

                    Vallis Paradisi

                    Tabula Rosettana